Move theme update logic to services.module.ts

This commit is contained in:
Thomas Rittson 2021-06-02 07:28:21 +10:00
parent 98f614aeda
commit 6edd600006
2 changed files with 4 additions and 8 deletions

View File

@ -124,14 +124,6 @@ export class AppComponent implements OnInit {
window.onkeypress = () => this.recordActivity();
});
this.platformUtilsService.onDefaultSystemThemeChange(async systemTheme => {
const theme = await this.storageService.get<string>(ConstantsService.themeKey);
if (theme == null) {
window.document.documentElement.classList.remove('theme_light', 'theme_dark');
window.document.documentElement.classList.add('theme_' + systemTheme);
}
});
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(async () => {
switch (message.command) {

View File

@ -157,6 +157,10 @@ export function initFactory(): Function {
let theme = await storageService.get<string>(ConstantsService.themeKey);
if (theme == null) {
theme = await platformUtilsService.getDefaultSystemTheme();
platformUtilsService.onDefaultSystemThemeChange(sysTheme => {
window.document.documentElement.classList.remove('theme_light', 'theme_dark');
window.document.documentElement.classList.add('theme_' + sysTheme);
});
}
htmlEl.classList.add('theme_' + theme);
stateService.save(ConstantsService.disableFaviconKey,