Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #232 from standardnotes/theme-fix
Browse files Browse the repository at this point in the history
Deactivate themes that have been uninstalled
  • Loading branch information
Mo Bitar committed Feb 11, 2020
2 parents 9e81124 + bac7064 commit 4e4b7c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/componentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
22 changes: 19 additions & 3 deletions src/style/StyleKit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
}
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -149,6 +157,13 @@ export default class StyleKit {
}
}

/**
* @private
*/
resetToSystemTheme() {
this.activateTheme(this.systemThemes[0]);
}

async resolveInitialTheme() {
const currentMode = this.currentDarkMode;
const runDefaultTheme = () => {
Expand Down Expand Up @@ -275,6 +290,7 @@ export default class StyleKit {

activateTheme(theme) {
const performActivation = () => {
this.setActiveTheme(theme);
this.assignThemeForMode({ theme: theme, mode: this.currentDarkMode });
};

Expand Down

0 comments on commit 4e4b7c9

Please sign in to comment.