diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 316a312..4a78ae4 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -105,6 +105,12 @@ export class AppComponent implements OnInit, OnDestroy { }); })); + let currentTheme = localStorage.getItem('ui-theme') ?? this.themeService.theme; + if (currentTheme == 'light' || currentTheme == 'dark') { + this.themeService.theme = currentTheme; + } else { + this.themeService.theme = 'dark'; + } this.overlayContainer.getContainerElement().classList.add(this.themeService.theme + '-theme'); this.addSubscription(this.events.listen('theme_change', data => { diff --git a/src/app/shared/services/theme.service.ts b/src/app/shared/services/theme.service.ts index f4a5ed4..d8e704e 100644 --- a/src/app/shared/services/theme.service.ts +++ b/src/app/shared/services/theme.service.ts @@ -14,7 +14,12 @@ export class ThemeService { set theme(value: 'light' | 'dark') { const previous = this._current(); + if (previous == value) { + return; + } + this._current.set(value); + localStorage.setItem('ui-theme', value); this.events.emit('theme_change', { previous_theme: previous, current_theme: value,