Move theme update logic to services.module.ts
This commit is contained in:
parent
98f614aeda
commit
6edd600006
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue