mirror of https://github.com/Chocobozzz/PeerTube
Fix logged in hotkeys
parent
0bb768a712
commit
905a40217d
|
@ -314,7 +314,7 @@ export class AppComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
private initHotkeys () {
|
private initHotkeys () {
|
||||||
this.hotkeysService.add([
|
this.hotkeysService.add([
|
||||||
new Hotkey([ '/', 's' ], () => {
|
new Hotkey([ 'Shift+/', 's' ], () => {
|
||||||
document.getElementById('search-video').focus()
|
document.getElementById('search-video').focus()
|
||||||
return false
|
return false
|
||||||
}, $localize`Focus the search bar`),
|
}, $localize`Focus the search bar`),
|
||||||
|
|
|
@ -36,7 +36,7 @@ export class AuthService {
|
||||||
loginChangedSource: Observable<AuthStatus>
|
loginChangedSource: Observable<AuthStatus>
|
||||||
userInformationLoaded = new ReplaySubject<boolean>(1)
|
userInformationLoaded = new ReplaySubject<boolean>(1)
|
||||||
tokensRefreshed = new ReplaySubject<void>(1)
|
tokensRefreshed = new ReplaySubject<void>(1)
|
||||||
hotkeys: Hotkey[]
|
loggedInHotkeys: Hotkey[]
|
||||||
|
|
||||||
private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID)
|
private clientId: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID)
|
||||||
private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET)
|
private clientSecret: string = peertubeLocalStorage.getItem(AuthService.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET)
|
||||||
|
@ -56,7 +56,7 @@ export class AuthService {
|
||||||
this.loginChangedSource = this.loginChanged.asObservable()
|
this.loginChangedSource = this.loginChanged.asObservable()
|
||||||
|
|
||||||
// Set HotKeys
|
// Set HotKeys
|
||||||
this.hotkeys = [
|
this.loggedInHotkeys = [
|
||||||
new Hotkey('m s', e => {
|
new Hotkey('m s', e => {
|
||||||
this.router.navigate([ '/videos/subscriptions' ])
|
this.router.navigate([ '/videos/subscriptions' ])
|
||||||
return false
|
return false
|
||||||
|
@ -78,6 +78,8 @@ export class AuthService {
|
||||||
|
|
||||||
buildAuthUser (userInfo: Partial<User>, tokens: OAuthUserTokens) {
|
buildAuthUser (userInfo: Partial<User>, tokens: OAuthUserTokens) {
|
||||||
this.user = new AuthUser(userInfo, tokens)
|
this.user = new AuthUser(userInfo, tokens)
|
||||||
|
|
||||||
|
this.hotkeysService.add(this.loggedInHotkeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
loadClientCredentials () {
|
loadClientCredentials () {
|
||||||
|
@ -194,8 +196,6 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular
|
||||||
this.user = null
|
this.user = null
|
||||||
|
|
||||||
this.setStatus(AuthStatus.LoggedOut)
|
this.setStatus(AuthStatus.LoggedOut)
|
||||||
|
|
||||||
this.hotkeysService.remove(this.hotkeys)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshAccessToken () {
|
refreshAccessToken () {
|
||||||
|
@ -284,8 +284,6 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular
|
||||||
|
|
||||||
this.setStatus(AuthStatus.LoggedIn)
|
this.setStatus(AuthStatus.LoggedIn)
|
||||||
this.userInformationLoaded.next(true)
|
this.userInformationLoaded.next(true)
|
||||||
|
|
||||||
this.hotkeysService.add(this.hotkeys)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleRefreshToken (obj: UserRefreshToken) {
|
private handleRefreshToken (obj: UserRefreshToken) {
|
||||||
|
@ -295,5 +293,11 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular
|
||||||
|
|
||||||
private setStatus (status: AuthStatus) {
|
private setStatus (status: AuthStatus) {
|
||||||
this.loginChanged.next(status)
|
this.loginChanged.next(status)
|
||||||
|
|
||||||
|
if (status === AuthStatus.LoggedIn) {
|
||||||
|
this.hotkeysService.add(this.loggedInHotkeys)
|
||||||
|
} else {
|
||||||
|
this.hotkeysService.remove(this.loggedInHotkeys)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue