X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fapp.component.ts;h=8fdab0c409478d62469444eb7ac76e55dccbc952;hb=ef2b5520f963deec43abd0a11881473c45965788;hp=95af89b19d464297eedd49bf70e0139d7755c559;hpb=af6766e3756c14e0ed0b1e1ea6470726f0e3a3f1;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 95af89b19..8fdab0c40 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -14,7 +14,8 @@ import { 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' @@ -30,6 +31,7 @@ import { BroadcastMessageLevel, HTMLServerConfig, UserRole } from '@shared/model import { MenuService } from './core/menu/menu.service' import { POP_STATE_MODAL_DISMISS } from './helpers' import { InstanceService } from './shared/shared-instance' +import { GlobalIconName } from './shared/shared-icons' @Component({ selector: 'my-app', @@ -70,6 +72,7 @@ export class AppComponent implements OnInit, AfterViewInit { private ngbConfig: NgbConfig, private loadingBar: LoadingBarService, private scrollService: ScrollService, + private userLocalStorage: UserLocalStorageService, public menu: MenuService ) { this.ngbConfig.animation = false @@ -86,6 +89,8 @@ export class AppComponent implements OnInit, AfterViewInit { ngOnInit () { document.getElementById('incompatible-browser').className += ' browser-ok' + this.loadUser() + this.serverConfig = this.serverService.getHTMLConfig() this.hooks.runAction('action:application.init', 'common') @@ -146,6 +151,17 @@ export class AppComponent implements OnInit, AfterViewInit { this.screenService.isBroadcastMessageDisplayed = false } + getNotificationIcon (message: { severity: 'success' | 'error' | 'info' }): GlobalIconName { + switch (message.severity) { + case 'error': + return 'cross' + case 'success': + return 'tick' + case 'info': + return 'help' + } + } + private initRouteEvents () { const eventsObs = this.router.events @@ -300,4 +316,15 @@ export class AppComponent implements OnInit, AfterViewInit { }, 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) + } }