Skip to content

Commit

Permalink
Merge pull request #1705 from Gauravjeetsingh/9.1.0-fixes
Browse files Browse the repository at this point in the history
Fix the build error and custom background deletion bug
  • Loading branch information
inderpreetsingh authored Jan 4, 2023
2 parents 745d900 + 4eed553 commit 5f1c176
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 6 additions & 2 deletions www/main/settings/components/ThemeContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,12 @@ const ThemeContainer = () => {
onRemove={() => {
removeCustomBackgroundFile(tile['background-image-path'].replace(/\\(\s)/g, ' '));
upsertCustomBackgrounds(setCustomThemes);
const currentThemeInstance = themes.filter((theme) => theme.key === currentTheme);
setDefaultBg(currentThemeInstance, setThemeBg, themeBg);
if (tile['background-image'] === themeBg.url.href) {
const currentThemeInstance = themes.filter(
(theme) => theme.key === currentTheme,
);
setDefaultBg(currentThemeInstance, setThemeBg, themeBg);
}
}}
/>
</React.Fragment>
Expand Down
7 changes: 1 addition & 6 deletions www/main/settings/utils/apply-theme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const remote = require('@electron/remote');

const { store } = remote.require('./app');
const analytics = remote.getGlobal('analytics');

export const setDefaultBg = (themeInstance, setThemeBg, themeBg) => {
Expand All @@ -15,15 +14,12 @@ export const setDefaultBg = (themeInstance, setThemeBg, themeBg) => {
if (themeBg !== themeBgObj) {
setThemeBg(themeBgObj);
}
return themeBgObj;
};

export const applyTheme = (themeInstance, isCustom, setTheme, setThemeBg, themeBg) => {
if (!isCustom) {
setTheme(themeInstance.key);
const themeBgObj = setDefaultBg(themeInstance, setThemeBg, themeBg);
/* TODO: move this to react state when porting viewer to react */
store.setUserPref('app.themebg', themeBgObj);
setDefaultBg(themeInstance, setThemeBg, themeBg);
} else {
const themeBgObj = {
type: 'custom',
Expand All @@ -32,7 +28,6 @@ export const applyTheme = (themeInstance, isCustom, setTheme, setThemeBg, themeB
if (themeBg !== themeBgObj) {
setThemeBg(themeBgObj);
}
store.setUserPref('app.themebg', themeBgObj);
}
global.core.platformMethod('updateSettings');
analytics.trackEvent('theme', themeInstance.key);
Expand Down

0 comments on commit 5f1c176

Please sign in to comment.