From 3dcea52b75cf9f937bd63792503a716a4ae9ad12 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Wed, 11 May 2022 16:30:40 +0200 Subject: [PATCH] System theme preference (#1800) * Add system preference to theme-settings * Add watching logic to check for dark theme settings * Add en system theme translation * Add explicit darkTheme option to browserWindow * Remove unnecessary themeSource line * Fix lint errors * Move to using main process messaging for theme change * Add system dataset selectors for themes * Fix lint errors * Change system theme to system default * Use system default for deciding background color of newWindow * Add baseTheme to state persistance * Use baseTheme on browserWindow creation * Fix lint errors * Improve window background logic * Catch settingsDb errors * Remove dark flash on light themes * Fix lint issues * Fix system default sync on multiple windows * Load database on each new window * Fix lint errors * Update compatibility for shared electron storage * Remove unused console log * Revert unnecessary changes * Fix window maximize white flash * Fix handleBaseTheme usage * Use data-system-theme instead of data-theme * Revert window maximize changes * Fix theme flash on new window open --- src/constants.js | 1 + src/datastores/handlers/base.js | 4 ++ src/index.ejs | 2 +- src/main/index.js | 37 ++++++++++++++++++- src/renderer/App.js | 25 +++++++++++-- src/renderer/App.vue | 1 + .../theme-settings/theme-settings.js | 2 + src/renderer/store/modules/settings.js | 2 +- src/renderer/themes.css | 4 +- static/locales/en-US.yaml | 1 + static/locales/en_GB.yaml | 1 + 11 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/constants.js b/src/constants.js index ba55e79b9..20aca01a3 100644 --- a/src/constants.js +++ b/src/constants.js @@ -12,6 +12,7 @@ const IpcChannels = { START_POWER_SAVE_BLOCKER: 'start-power-save-blocker', CREATE_NEW_WINDOW: 'create-new-window', OPEN_IN_EXTERNAL_PLAYER: 'open-in-external-player', + NATIVE_THEME_UPDATE: 'native-theme-update', DB_SETTINGS: 'db-settings', DB_HISTORY: 'db-history', diff --git a/src/datastores/handlers/base.js b/src/datastores/handlers/base.js index 90b9d183d..125005251 100644 --- a/src/datastores/handlers/base.js +++ b/src/datastores/handlers/base.js @@ -27,6 +27,10 @@ class Settings { return db.settings.findOne({ _id: 'bounds' }) } + static _findTheme() { + return db.settings.findOne({ _id: 'baseTheme' }) + } + static _updateBounds(value) { return db.settings.update({ _id: 'bounds' }, { _id: 'bounds', value }, { upsert: true }) } diff --git a/src/index.ejs b/src/index.ejs index 11d81f7d1..f0dad7e03 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -16,7 +16,7 @@ <% } %> - +