Skip to content

Commit

Permalink
fix: theme entitlement logic
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Feb 18, 2022
1 parent fbabbbb commit 0369d03
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions app/assets/javascripts/services/themeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
}
}
}

Expand All @@ -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;
}
}
}

Expand Down

0 comments on commit 0369d03

Please sign in to comment.