Merge pull request #232 from standardnotes/theme-fix

Deactivate themes that have been uninstalled
This commit is contained in:
Mo Bitar
2020-02-11 10:40:38 -06:00
committed by GitHub
2 changed files with 20 additions and 4 deletions

View File

@@ -131,7 +131,7 @@ export default class ComponentManager extends SNComponentManager {
}
if (editor) {
if (note.content.mobilePrefersPlainEditor == true) {
if (note.content.mobilePrefersPlainEditor === true) {
note.content.mobilePrefersPlainEditor = false;
note.setDirty(true);
}

View File

@@ -49,12 +49,20 @@ export default class StyleKit {
this.activeTheme.isSwapIn = false;
}
}
const activeUuid = this.activeTheme.uuid;
for (const theme of deletedItems) {
if (activeUuid === theme.uuid) {
this.resetToSystemTheme();
return;
}
}
}
);
this.signoutObserver = Auth.get().addEventHandler(event => {
if (event === SFAuthManager.DidSignOutEvent) {
this.activateTheme(this.systemThemes[0]);
this.resetToSystemTheme();
}
});
}
@@ -92,10 +100,10 @@ export default class StyleKit {
/**
* If we're changing the theme for a specific mode and we're currently on
* that mode, then set this theme as active
* that mode, then activate this theme.
*/
if (this.currentDarkMode === mode && this.activeTheme.uuid !== theme.uuid) {
this.setActiveTheme(theme);
this.activateTheme(theme);
}
}
@@ -149,6 +157,13 @@ export default class StyleKit {
}
}
/**
* @private
*/
resetToSystemTheme() {
this.activateTheme(this.systemThemes[0]);
}
async resolveInitialTheme() {
const currentMode = this.currentDarkMode;
const runDefaultTheme = () => {
@@ -275,6 +290,7 @@ export default class StyleKit {
activateTheme(theme) {
const performActivation = () => {
this.setActiveTheme(theme);
this.assignThemeForMode({ theme: theme, mode: this.currentDarkMode });
};