Fix logged in hotkeys

pull/6003/head
Chocobozzz 2023-10-10 08:35:53 +02:00
parent 0bb768a712
commit 905a40217d
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 11 additions and 7 deletions

View File

@ -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`),

View File

@ -36,7 +36,7 @@ export class AuthService {
loginChangedSource: Observable<AuthStatus>
userInformationLoaded = new ReplaySubject<boolean>(1)
tokensRefreshed = new ReplaySubject<void>(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<User>, 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)
}
}
}