From 6edd60000635377991a46833c8b7f95b9380952f Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Wed, 2 Jun 2021 07:28:21 +1000 Subject: [PATCH] Move theme update logic to services.module.ts --- src/app/app.component.ts | 8 -------- src/app/services.module.ts | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4511f52e9c..f959f91178 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -124,14 +124,6 @@ export class AppComponent implements OnInit { window.onkeypress = () => this.recordActivity(); }); - this.platformUtilsService.onDefaultSystemThemeChange(async systemTheme => { - const theme = await this.storageService.get(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) { diff --git a/src/app/services.module.ts b/src/app/services.module.ts index bfdf235ccd..b6a24f9fd8 100644 --- a/src/app/services.module.ts +++ b/src/app/services.module.ts @@ -157,6 +157,10 @@ export function initFactory(): Function { let theme = await storageService.get(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,