+ this.injectJS()
+ this.injectCSS()
+ this.injectBroadcastMessage()
+
+ this.serverService.configReloaded
+ .subscribe(config => {
+ this.serverConfig = config
+
+ this.injectBroadcastMessage()
+ this.injectCSS()
+
+ // Don't reinject JS since it could conflict with existing one
+ })
+
+ this.initHotkeys()
+
+ this.location.onPopState(() => this.modalService.dismissAll(POP_STATE_MODAL_DISMISS))
+
+ this.openModalsIfNeeded()
+
+ this.document.documentElement.lang = getShortLocale(this.localeId)
+ this.document.documentElement.dir = getLocaleDirection(this.localeId)
+ }
+
+ ngAfterViewInit () {
+ this.pluginService.initializeCustomModal(this.customModal)
+ }
+
+ getToggleTitle () {
+ if (this.menu.isDisplayed()) return $localize`Close the left menu`
+
+ return $localize`Open the left menu`
+ }
+
+ isUserLoggedIn () {
+ return this.authService.isLoggedIn()
+ }
+
+ hideBroadcastMessage () {
+ peertubeLocalStorage.setItem(AppComponent.BROADCAST_MESSAGE_KEY, this.serverConfig.broadcastMessage.message)
+
+ this.broadcastMessage = null
+ this.screenService.isBroadcastMessageDisplayed = false
+ }
+
+ private initRouteEvents () {
+ const eventsObs = this.router.events
+
+ // Plugin hooks
+ this.peertubeRouter.getNavigationEndEvents().subscribe(e => {
+ this.hooks.runAction('action:router.navigation-end', 'common', { path: e.url })
+ })
+
+ // Automatically hide/display the menu
+ eventsObs.pipe(
+ filter((e: Event): e is GuardsCheckStart => e instanceof GuardsCheckStart),
+ filter(() => this.screenService.isInSmallView() || this.screenService.isInTouchScreen())
+ ).subscribe(() => this.menu.setMenuDisplay(false)) // User clicked on a link in the menu, change the page
+
+ // Handle lazy loaded module
+ eventsObs.pipe(
+ filter((e: Event): e is RouteConfigLoadStart => e instanceof RouteConfigLoadStart)
+ ).subscribe(() => this.loadingBar.useRef().start())
+
+ eventsObs.pipe(
+ filter((e: Event): e is RouteConfigLoadEnd => e instanceof RouteConfigLoadEnd)
+ ).subscribe(() => this.loadingBar.useRef().complete())
+ }
+
+ private async injectBroadcastMessage () {
+ this.broadcastMessage = null
+ this.screenService.isBroadcastMessageDisplayed = false
+
+ const messageConfig = this.serverConfig.broadcastMessage
+
+ if (messageConfig.enabled) {
+ // Already dismissed this message?
+ if (messageConfig.dismissable && localStorage.getItem(AppComponent.BROADCAST_MESSAGE_KEY) === messageConfig.message) {
+ return
+ }
+
+ const classes: { [id in BroadcastMessageLevel]: string } = {
+ info: 'alert-info',
+ warning: 'alert-warning',
+ error: 'alert-danger'
+ }