diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index c22b6ef0b..d38e9eea1 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -314,7 +314,7 @@ export class AppComponent implements OnInit, AfterViewInit { private initHotkeys () { this.hotkeysService.add([ - new Hotkey([ '/', 's' ], () => { + new Hotkey([ 'Shift+/', 's' ], () => { document.getElementById('search-video').focus() return false }, $localize`Focus the search bar`), diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts index 2ec4a4b7e..cadf78c0c 100644 --- a/client/src/app/core/auth/auth.service.ts +++ b/client/src/app/core/auth/auth.service.ts @@ -36,7 +36,7 @@ export class AuthService { loginChangedSource: Observable userInformationLoaded = new ReplaySubject(1) tokensRefreshed = new ReplaySubject(1) - hotkeys: Hotkey[] + loggedInHotkeys: Hotkey[] 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) @@ -56,7 +56,7 @@ export class AuthService { this.loginChangedSource = this.loginChanged.asObservable() // Set HotKeys - this.hotkeys = [ + this.loggedInHotkeys = [ new Hotkey('m s', e => { this.router.navigate([ '/videos/subscriptions' ]) return false @@ -78,6 +78,8 @@ export class AuthService { buildAuthUser (userInfo: Partial, tokens: OAuthUserTokens) { this.user = new AuthUser(userInfo, tokens) + + this.hotkeysService.add(this.loggedInHotkeys) } loadClientCredentials () { @@ -194,8 +196,6 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular this.user = null this.setStatus(AuthStatus.LoggedOut) - - this.hotkeysService.remove(this.hotkeys) } refreshAccessToken () { @@ -284,8 +284,6 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular this.setStatus(AuthStatus.LoggedIn) this.userInformationLoaded.next(true) - - this.hotkeysService.add(this.hotkeys) } private handleRefreshToken (obj: UserRefreshToken) { @@ -295,5 +293,11 @@ Ensure you have correctly configured PeerTube (config/ directory), in particular private setStatus (status: AuthStatus) { this.loginChanged.next(status) + + if (status === AuthStatus.LoggedIn) { + this.hotkeysService.add(this.loggedInHotkeys) + } else { + this.hotkeysService.remove(this.loggedInHotkeys) + } } }