diff --git a/src/app/components/shared/header/header.component.ts b/src/app/components/shared/header/header.component.ts index af51e148a7973d11febe35b944d733dc985ff716..6c0490fb1efdcf9eee8045c7214f178dcecfed71 100644 --- a/src/app/components/shared/header/header.component.ts +++ b/src/app/components/shared/header/header.component.ts @@ -18,7 +18,7 @@ import { ThemeService } from '../../../../theme/theme.service'; }) export class HeaderComponent implements OnInit { user: User; - themeClass = localStorage.getItem('classNameOfTheme'); + themeClass = localStorage.getItem('theme'); constructor(public location: Location, private authenticationService: AuthenticationService, @@ -67,11 +67,10 @@ export class HeaderComponent implements OnInit { changeTheme(theme) { this.themeClass = theme; - localStorage.setItem('classNameOfTheme', theme); if (theme === '') { - this.themeService.setActiveThem('arsnovaTheme'); + this.themeService.activate('arsnovaTheme'); } else { - this.themeService.setActiveThem(theme); + this.themeService.activate(theme); } } diff --git a/src/app/components/shared/login/login.component.ts b/src/app/components/shared/login/login.component.ts index 9bda7d3ea12443308ec89a4d841200805ffda5b5..bd1d3126aae699186995bf5d099836853f3efd67 100644 --- a/src/app/components/shared/login/login.component.ts +++ b/src/app/components/shared/login/login.component.ts @@ -106,8 +106,10 @@ export class LoginComponent implements OnInit, OnChanges { this.dialog.closeAll(); if (this.isStandard) { if (this.role === UserRole.CREATOR) { + const theme = 'dark'; this.router.navigate(['creator']); - this.themeService.setActiveThem('dark'); + this.themeService.activate(theme); + localStorage.setItem('theme', theme); } else { this.router.navigate(['participant']); } diff --git a/src/theme/theme.directive.ts b/src/theme/theme.directive.ts index 41a493da22e7284bc882e9fc6285ac0c9b217db4..4202d0503f24cec72957090d239ef4f7856b9404 100644 --- a/src/theme/theme.directive.ts +++ b/src/theme/theme.directive.ts @@ -21,7 +21,7 @@ export class ThemeDirective implements OnInit, OnDestroy { ngOnInit() { this.updateTheme(this.themeName); - this.themService.getActiveTheme() + this.themService.getTheme() .subscribe(themeName => { this.themeName = themeName; this.updateTheme(this.themeName); diff --git a/src/theme/theme.service.ts b/src/theme/theme.service.ts index 9c56dfb379aacc5f0df11e7ea62560038d9838e3..cb045b6ea6a404e8589504496ffd6b1b0b242755 100644 --- a/src/theme/theme.service.ts +++ b/src/theme/theme.service.ts @@ -5,16 +5,17 @@ import { BehaviorSubject } from 'rxjs'; providedIn: 'root' }) export class ThemeService { - themeName = localStorage.getItem('classNameOfTheme'); + themeName = localStorage.getItem('theme'); private activeThem = new BehaviorSubject(this.themeName); constructor() { } - public getActiveTheme() { + public getTheme() { return this.activeThem.asObservable(); } - public setActiveThem(name) { + public activate(name) { this.activeThem.next(name); + localStorage.setItem('theme', name); } }