Skip to content
Snippets Groups Projects
Commit 119d3560 authored by Lukas Mauß's avatar Lukas Mauß
Browse files

Fix theme service

parent 1398f2cf
Branches
Tags
No related merge requests found
...@@ -18,7 +18,7 @@ import { ThemeService } from '../../../../theme/theme.service'; ...@@ -18,7 +18,7 @@ import { ThemeService } from '../../../../theme/theme.service';
}) })
export class HeaderComponent implements OnInit { export class HeaderComponent implements OnInit {
user: User; user: User;
themeClass = localStorage.getItem('classNameOfTheme'); themeClass = localStorage.getItem('theme');
constructor(public location: Location, constructor(public location: Location,
private authenticationService: AuthenticationService, private authenticationService: AuthenticationService,
...@@ -67,11 +67,10 @@ export class HeaderComponent implements OnInit { ...@@ -67,11 +67,10 @@ export class HeaderComponent implements OnInit {
changeTheme(theme) { changeTheme(theme) {
this.themeClass = theme; this.themeClass = theme;
localStorage.setItem('classNameOfTheme', theme);
if (theme === '') { if (theme === '') {
this.themeService.setActiveThem('arsnovaTheme'); this.themeService.activate('arsnovaTheme');
} else { } else {
this.themeService.setActiveThem(theme); this.themeService.activate(theme);
} }
} }
......
...@@ -106,8 +106,10 @@ export class LoginComponent implements OnInit, OnChanges { ...@@ -106,8 +106,10 @@ export class LoginComponent implements OnInit, OnChanges {
this.dialog.closeAll(); this.dialog.closeAll();
if (this.isStandard) { if (this.isStandard) {
if (this.role === UserRole.CREATOR) { if (this.role === UserRole.CREATOR) {
const theme = 'dark';
this.router.navigate(['creator']); this.router.navigate(['creator']);
this.themeService.setActiveThem('dark'); this.themeService.activate(theme);
localStorage.setItem('theme', theme);
} else { } else {
this.router.navigate(['participant']); this.router.navigate(['participant']);
} }
......
...@@ -21,7 +21,7 @@ export class ThemeDirective implements OnInit, OnDestroy { ...@@ -21,7 +21,7 @@ export class ThemeDirective implements OnInit, OnDestroy {
ngOnInit() { ngOnInit() {
this.updateTheme(this.themeName); this.updateTheme(this.themeName);
this.themService.getActiveTheme() this.themService.getTheme()
.subscribe(themeName => { .subscribe(themeName => {
this.themeName = themeName; this.themeName = themeName;
this.updateTheme(this.themeName); this.updateTheme(this.themeName);
......
...@@ -5,16 +5,17 @@ import { BehaviorSubject } from 'rxjs'; ...@@ -5,16 +5,17 @@ import { BehaviorSubject } from 'rxjs';
providedIn: 'root' providedIn: 'root'
}) })
export class ThemeService { export class ThemeService {
themeName = localStorage.getItem('classNameOfTheme'); themeName = localStorage.getItem('theme');
private activeThem = new BehaviorSubject(this.themeName); private activeThem = new BehaviorSubject(this.themeName);
constructor() { } constructor() { }
public getActiveTheme() { public getTheme() {
return this.activeThem.asObservable(); return this.activeThem.asObservable();
} }
public setActiveThem(name) { public activate(name) {
this.activeThem.next(name); this.activeThem.next(name);
localStorage.setItem('theme', name);
} }
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment