fix: theme entitlement logic

This commit is contained in:
Mo
2022-02-18 08:20:39 -06:00
parent fbabbbb7d3
commit 0369d03542

View File

@@ -100,20 +100,6 @@ export class ThemeManager extends ApplicationService {
this.setThemeAsPerColorScheme(prefersDarkColorScheme.matches);
break;
}
case ApplicationEvent.LocalDataLoaded: {
const themes = this.application.getDisplayableItems(
ContentType.Theme
) as SNTheme[];
themes.forEach((theme) => {
if (
theme.active &&
this.application.getFeatureStatus(theme.identifier) !==
FeatureStatus.Entitled
) {
this.application.toggleTheme(theme);
}
});
}
}
}
@@ -137,13 +123,19 @@ export class ThemeManager extends ApplicationService {
let hasChange = false;
for (const themeUuid of this.activeThemes) {
const theme = this.application.findItem(themeUuid) as SNTheme;
if (
!theme ||
this.application.getFeatureStatus(theme.identifier) !==
FeatureStatus.Entitled
) {
if (!theme) {
this.deactivateTheme(themeUuid);
hasChange = true;
} else {
const status = this.application.getFeatureStatus(theme.identifier);
if (status !== FeatureStatus.Entitled) {
if (theme.active) {
this.application.toggleTheme(theme);
} else {
this.deactivateTheme(theme.uuid);
}
hasChange = true;
}
}
}