From 4eed553a95c3af42339afdb5d7597a8a58c72a54 Mon Sep 17 00:00:00 2001 From: Gauravjeet Singh Date: Wed, 4 Jan 2023 12:47:45 +0530 Subject: [PATCH] fix: resolve the build error with travis/appveyor - Also, remove the custom background on deletion only if its active --- www/main/settings/components/ThemeContainer.jsx | 8 ++++++-- www/main/settings/utils/apply-theme.js | 7 +------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/www/main/settings/components/ThemeContainer.jsx b/www/main/settings/components/ThemeContainer.jsx index 3e3620e60..78929d2c1 100644 --- a/www/main/settings/components/ThemeContainer.jsx +++ b/www/main/settings/components/ThemeContainer.jsx @@ -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); + } }} /> diff --git a/www/main/settings/utils/apply-theme.js b/www/main/settings/utils/apply-theme.js index 94a566d25..e4f3e7be8 100644 --- a/www/main/settings/utils/apply-theme.js +++ b/www/main/settings/utils/apply-theme.js @@ -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) => { @@ -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', @@ -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);