import { Hotkey, HotkeysService } from 'angular2-hotkeys'
-import { forkJoin } from 'rxjs'
+import { forkJoin, delay } from 'rxjs'
import { filter, first, map } from 'rxjs/operators'
import { DOCUMENT, getLocaleDirection, PlatformLocation } from '@angular/common'
import { AfterViewInit, Component, Inject, LOCALE_ID, OnInit, ViewChild } from '@angular/core'
ScrollService,
ServerService,
ThemeService,
- User
+ User,
+ UserLocalStorageService
} from '@app/core'
import { HooksService } from '@app/core/plugins/hooks.service'
import { PluginService } from '@app/core/plugins/plugin.service'
private ngbConfig: NgbConfig,
private loadingBar: LoadingBarService,
private scrollService: ScrollService,
+ private userLocalStorage: UserLocalStorageService,
public menu: MenuService
) {
this.ngbConfig.animation = false
ngOnInit () {
document.getElementById('incompatible-browser').className += ' browser-ok'
+ this.loadUser()
+
this.serverConfig = this.serverService.getHTMLConfig()
this.hooks.runAction('action:application.init', 'common')
private openModalsIfNeeded () {
const userSub = this.authService.userInformationLoaded
- .pipe(map(() => this.authService.getUser()))
+ .pipe(
+ delay(0), // Wait for modals creations
+ map(() => this.authService.getUser())
+ )
// Admin modal
userSub.pipe(
}, undefined, $localize`Go to the videos upload page`)
])
}
+
+ private loadUser () {
+ const tokens = this.userLocalStorage.getTokens()
+ if (!tokens) return
+
+ const user = this.userLocalStorage.getLoggedInUser()
+ if (!user) return
+
+ // Initialize user
+ this.authService.buildAuthUser(user, tokens)
+ }
}