From e6e184c4127f2cca69c5f0314e916b11692e743f Mon Sep 17 00:00:00 2001 From: Shazib Hussain Date: Mon, 20 Nov 2023 18:16:25 +0000 Subject: [PATCH] Fix Electron Build (#1926) --- packages/desktop-client/src/browser-preload.browser.js | 4 +++- packages/desktop-client/src/global-events.js | 4 ---- packages/desktop-electron/index.js | 8 ++++++++ packages/desktop-electron/preload.js | 4 +++- upcoming-release-notes/1926.md | 6 ++++++ 5 files changed, 20 insertions(+), 6 deletions(-) create mode 100644 upcoming-release-notes/1926.md diff --git a/packages/desktop-client/src/browser-preload.browser.js b/packages/desktop-client/src/browser-preload.browser.js index 2fa3e0fae5b..6d5b7dd7c35 100644 --- a/packages/desktop-client/src/browser-preload.browser.js +++ b/packages/desktop-client/src/browser-preload.browser.js @@ -129,7 +129,9 @@ global.Actual = { return worker; }, - setTheme: () => {}, + setTheme: theme => { + window.__actionsForMenu.saveGlobalPrefs({ theme: theme }); + }, }; document.addEventListener('keydown', e => { diff --git a/packages/desktop-client/src/global-events.js b/packages/desktop-client/src/global-events.js index 1cc54f8766f..258e13ea212 100644 --- a/packages/desktop-client/src/global-events.js +++ b/packages/desktop-client/src/global-events.js @@ -14,10 +14,6 @@ export function handleGlobalEvents(actions, store) { // to update. }); - global.Actual.setTheme = theme => { - actions.saveGlobalPrefs({ theme }); - }; - listen('server-error', info => { actions.addGenericErrorNotification(); }); diff --git a/packages/desktop-electron/index.js b/packages/desktop-electron/index.js index 39f44c4e20e..f67e4b678bc 100644 --- a/packages/desktop-electron/index.js +++ b/packages/desktop-electron/index.js @@ -407,3 +407,11 @@ ipcMain.on('apply-update', () => { ipcMain.on('update-menu', (event, isBudgetOpen) => { updateMenu(isBudgetOpen); }); + +ipcMain.on('set-theme', theme => { + let obj = { theme: theme }; + + clientWin.webContents.executeJavaScript( + `window.__actionsForMenu && window.__actionsForMenu.saveGlobalPrefs(${obj})`, + ); +}); diff --git a/packages/desktop-electron/preload.js b/packages/desktop-electron/preload.js index 7bfb4a37c5b..759d4fc201a 100644 --- a/packages/desktop-electron/preload.js +++ b/packages/desktop-electron/preload.js @@ -55,5 +55,7 @@ contextBridge.exposeInMainWorld('Actual', { return socketPromise; }, - setTheme: () => {}, + setTheme: theme => { + ipcRenderer.send('set-theme', theme); + }, }); diff --git a/upcoming-release-notes/1926.md b/upcoming-release-notes/1926.md new file mode 100644 index 00000000000..44a2e3857a8 --- /dev/null +++ b/upcoming-release-notes/1926.md @@ -0,0 +1,6 @@ +--- +category: Bugfix +authors: [Shazib] +--- + +Fix issue with electron builds being stuck on a blank screen.