fix: apply active themes after features updated

This commit is contained in:
Mo
2022-02-22 14:03:28 -06:00
parent af69a02555
commit 3d6c10b70e

View File

@@ -84,7 +84,7 @@ export class ThemeManager extends ApplicationService {
break; break;
} }
case ApplicationEvent.FeaturesUpdated: { case ApplicationEvent.FeaturesUpdated: {
this.reloadThemeStatus(); this.handleFeaturesUpdated();
break; break;
} }
case ApplicationEvent.Launched: { case ApplicationEvent.Launched: {
@@ -119,7 +119,7 @@ export class ThemeManager extends ApplicationService {
super.deinit(); super.deinit();
} }
private reloadThemeStatus(): void { private handleFeaturesUpdated(): void {
let hasChange = false; let hasChange = false;
for (const themeUuid of this.activeThemes) { for (const themeUuid of this.activeThemes) {
const theme = this.application.findItem(themeUuid) as SNTheme; const theme = this.application.findItem(themeUuid) as SNTheme;
@@ -139,6 +139,17 @@ export class ThemeManager extends ApplicationService {
} }
} }
const activeThemes = (
this.application.getItems(ContentType.Theme) as SNTheme[]
).filter((theme) => theme.active);
for (const theme of activeThemes) {
if (!this.activeThemes.includes(theme.uuid)) {
this.activateTheme(theme);
hasChange = true;
}
}
if (hasChange) { if (hasChange) {
this.cacheThemeState(); this.cacheThemeState();
} }