From e1a2d43c9db6b6afb2e6a3148b966b58368d084b Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Thu, 7 Oct 2021 19:41:01 +0300 Subject: [PATCH 01/29] Add system preference to theme-settings --- src/renderer/components/theme-settings/theme-settings.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/renderer/components/theme-settings/theme-settings.js b/src/renderer/components/theme-settings/theme-settings.js index b38e95a010d35..748d0273e00cf 100644 --- a/src/renderer/components/theme-settings/theme-settings.js +++ b/src/renderer/components/theme-settings/theme-settings.js @@ -35,6 +35,7 @@ export default Vue.extend({ baseThemeValues: [ 'light', 'dark', + 'system', 'black', 'dracula' ], @@ -99,6 +100,7 @@ export default Vue.extend({ return [ this.$t('Settings.Theme Settings.Base Theme.Light'), this.$t('Settings.Theme Settings.Base Theme.Dark'), + this.$t('Settings.Theme Settings.Base Theme.System'), this.$t('Settings.Theme Settings.Base Theme.Black'), this.$t('Settings.Theme Settings.Base Theme.Dracula') ] From 2c04d3c44192443a8a4d4ecf01e915cdf29bcd9d Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Thu, 7 Oct 2021 19:41:56 +0300 Subject: [PATCH 02/29] Add watching logic to check for dark theme settings --- src/renderer/App.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/renderer/App.js b/src/renderer/App.js index ec2ebd1372154..0ac467477e651 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -124,6 +124,7 @@ export default Vue.extend({ created () { this.checkThemeSettings() this.setWindowTitle() + this.watchSystemTheme() }, mounted: function () { this.grabUserSettings().then(async () => { @@ -186,11 +187,26 @@ export default Vue.extend({ this.updateTheme(theme) }, + watchSystemTheme: function () { + window.matchMedia('(prefers-color-scheme: dark)').onchange = (e) => { + this.checkThemeSettings() + } + }, + + getThemeClass: function (baseTheme) { + if (baseTheme === 'system') { + return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' + } + + return baseTheme + }, + updateTheme: function (theme) { console.log(theme) - const className = `${theme.baseTheme} ${theme.mainColor} ${theme.secColor}` + let className = `${this.getThemeClass(theme.baseTheme)} ${theme.mainColor} ${theme.secColor}` const body = document.getElementsByTagName('body')[0] body.className = className + localStorage.setItem('baseTheme', theme.baseTheme) localStorage.setItem('mainColor', theme.mainColor) localStorage.setItem('secColor', theme.secColor) From aa2686cc57a2e04dd0475eafd072589a5544b50e Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Thu, 7 Oct 2021 19:44:53 +0300 Subject: [PATCH 03/29] Add en system theme translation --- static/locales/en-US.yaml | 1 + static/locales/en_GB.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 324f214fd93ff..708dfcb64d8cc 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -163,6 +163,7 @@ Settings: Base Theme: Base Theme Black: Black Dark: Dark + System: System Light: Light Dracula: Dracula Main Color Theme: diff --git a/static/locales/en_GB.yaml b/static/locales/en_GB.yaml index a298e962ecd42..3ea3ff2cceae5 100644 --- a/static/locales/en_GB.yaml +++ b/static/locales/en_GB.yaml @@ -158,6 +158,7 @@ Settings: Base Theme: 'Base theme' Black: 'Black' Dark: 'Dark' + System: 'System' Light: 'Light' Dracula: 'Dracula' Main Color Theme: From 125ab92272c6e4d39eab6741db42c38b2cdb4046 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Fri, 8 Oct 2021 09:37:10 +0300 Subject: [PATCH 04/29] Add explicit darkTheme option to browserWindow --- src/main/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index c594cfbd6b589..e61fcd05038a9 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -1,6 +1,6 @@ import { app, BrowserWindow, dialog, Menu, ipcMain, - powerSaveBlocker, screen, session, shell + powerSaveBlocker, screen, session, shell, nativeTheme } from 'electron' import path from 'path' import cp from 'child_process' @@ -38,6 +38,8 @@ function runApp() { let mainWindow let startupUrl + nativeTheme.themeSource = 'system' + // CORS somehow gets re-enabled in Electron v9.0.4 // This line disables it. // This line can possible be removed if the issue is fixed upstream @@ -177,6 +179,7 @@ function runApp() { */ const commonBrowserWindowOptions = { backgroundColor: '#212121', + darkTheme: nativeTheme.shouldUseDarkColors, icon: isDev ? path.join(__dirname, '../../_icons/iconColor.png') /* eslint-disable-next-line */ From 5343f8a02bbed66fa97a23bbae484b1f762e40d1 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Fri, 8 Oct 2021 09:41:29 +0300 Subject: [PATCH 05/29] Remove unnecessary themeSource line --- src/main/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index e61fcd05038a9..42fa9f2d2709e 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -38,8 +38,6 @@ function runApp() { let mainWindow let startupUrl - nativeTheme.themeSource = 'system' - // CORS somehow gets re-enabled in Electron v9.0.4 // This line disables it. // This line can possible be removed if the issue is fixed upstream From 2893fbf141b0b47e9952a4ec746b27bfeb0abbff Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Fri, 8 Oct 2021 09:44:08 +0300 Subject: [PATCH 06/29] Fix lint errors --- src/renderer/App.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/App.js b/src/renderer/App.js index 0ac467477e651..0d680eedc6e93 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -203,7 +203,7 @@ export default Vue.extend({ updateTheme: function (theme) { console.log(theme) - let className = `${this.getThemeClass(theme.baseTheme)} ${theme.mainColor} ${theme.secColor}` + const className = `${this.getThemeClass(theme.baseTheme)} ${theme.mainColor} ${theme.secColor}` const body = document.getElementsByTagName('body')[0] body.className = className @@ -465,7 +465,7 @@ export default Vue.extend({ 'setInvidiousInstancesList' ]), - setWindowTitle: function() { + setWindowTitle: function () { if (this.windowTitle !== null) { document.title = this.windowTitle } From 607fc15120ef39cb8dd38f56611ff2860fa1fa6d Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sat, 9 Oct 2021 11:49:21 +0300 Subject: [PATCH 07/29] Move to using main process messaging for theme change --- src/main/index.js | 10 ++++++++++ src/renderer/App.js | 40 ++++++++++++++++++++++------------------ 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 42fa9f2d2709e..83d9cde26eddc 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -338,7 +338,17 @@ function runApp() { app.quit() }) +<<<<<<< HEAD ipcMain.on(IpcChannels.ENABLE_PROXY, (_, url) => { +======= + nativeTheme.on('updated', () => { + if (mainWindow) { + mainWindow.webContents.send('native-theme-update', nativeTheme.shouldUseDarkColors) + } + }) + + ipcMain.on('enableProxy', (_, url) => { +>>>>>>> 4b5a72ae (Move to using main process messaging for theme change) console.log(url) session.defaultSession.setProxy({ proxyRules: url diff --git a/src/renderer/App.js b/src/renderer/App.js index 0d680eedc6e93..cfb27c7f5b19e 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -122,9 +122,9 @@ export default Vue.extend({ } }, created () { + this.setBodytheme() this.checkThemeSettings() this.setWindowTitle() - this.watchSystemTheme() }, mounted: function () { this.grabUserSettings().then(async () => { @@ -144,6 +144,7 @@ export default Vue.extend({ this.activateKeyboardShortcuts() this.openAllLinksExternally() this.enableOpenUrl() + this.watchSystemTheme() await this.checkExternalPlayer() } @@ -161,6 +162,14 @@ export default Vue.extend({ }) }, methods: { + setBodytheme: function () { + if (window.matchMedia('(prefers-color-scheme: dark)').matches) { + document.body.dataset.theme = 'dark' + } else { + document.body.dataset.theme = 'light' + } + }, + checkThemeSettings: function () { let baseTheme = localStorage.getItem('baseTheme') let mainColor = localStorage.getItem('mainColor') @@ -187,25 +196,10 @@ export default Vue.extend({ this.updateTheme(theme) }, - watchSystemTheme: function () { - window.matchMedia('(prefers-color-scheme: dark)').onchange = (e) => { - this.checkThemeSettings() - } - }, - - getThemeClass: function (baseTheme) { - if (baseTheme === 'system') { - return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' - } - - return baseTheme - }, - updateTheme: function (theme) { console.log(theme) - const className = `${this.getThemeClass(theme.baseTheme)} ${theme.mainColor} ${theme.secColor}` - const body = document.getElementsByTagName('body')[0] - body.className = className + const className = `${theme.baseTheme} ${theme.mainColor} ${theme.secColor}` + document.body.className = className localStorage.setItem('baseTheme', theme.baseTheme) localStorage.setItem('mainColor', theme.mainColor) @@ -439,6 +433,16 @@ export default Vue.extend({ }) }, + /** + * Linux fix for dynamically updating theme preference, this works on + * all systems running the electron app. + */ + watchSystemTheme: function () { + ipcRenderer.on('native-theme-update', (event, shouldUseDarkColors) => { + document.body.dataset.theme = shouldUseDarkColors ? 'dark' : 'light' + }); + }, + enableOpenUrl: function () { ipcRenderer.on('openUrl', (event, url) => { if (url) { From f07a3a25fefe33b1a61e8e59bcca428453b93782 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sat, 9 Oct 2021 11:49:32 +0300 Subject: [PATCH 08/29] Add system dataset selectors for themes --- src/renderer/themes.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/themes.css b/src/renderer/themes.css index 73e365fba2164..d22ec1ea08061 100644 --- a/src/renderer/themes.css +++ b/src/renderer/themes.css @@ -1,4 +1,4 @@ -.light { +.system[data-theme*='light'], .light { --primary-text-color: #212121; --secondary-text-color: #424242; --tertiary-text-color: #757575; @@ -22,7 +22,7 @@ --logo-text: url("~../../_icons/textColorSmall.png"); } -.dark { +.system[data-theme*='dark'], .dark { --primary-text-color: #EEEEEE; --secondary-text-color: #ddd; --tertiary-text-color: #999; From f2ef15c11dd871c330474a5a4535cee8fe81762a Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sat, 9 Oct 2021 11:50:38 +0300 Subject: [PATCH 09/29] Fix lint errors --- src/renderer/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/App.js b/src/renderer/App.js index cfb27c7f5b19e..3208ab4f37e7b 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -440,7 +440,7 @@ export default Vue.extend({ watchSystemTheme: function () { ipcRenderer.on('native-theme-update', (event, shouldUseDarkColors) => { document.body.dataset.theme = shouldUseDarkColors ? 'dark' : 'light' - }); + }) }, enableOpenUrl: function () { From ee930306603c5e2af92049c764d45c3a4b065b36 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sun, 10 Oct 2021 16:58:33 +0300 Subject: [PATCH 10/29] Change system theme to system default --- src/renderer/components/theme-settings/theme-settings.js | 4 ++-- static/locales/en-US.yaml | 2 +- static/locales/en_GB.yaml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderer/components/theme-settings/theme-settings.js b/src/renderer/components/theme-settings/theme-settings.js index 748d0273e00cf..109bbe3980e9e 100644 --- a/src/renderer/components/theme-settings/theme-settings.js +++ b/src/renderer/components/theme-settings/theme-settings.js @@ -33,9 +33,9 @@ export default Vue.extend({ 'no' ], baseThemeValues: [ + 'system', 'light', 'dark', - 'system', 'black', 'dracula' ], @@ -98,9 +98,9 @@ export default Vue.extend({ baseThemeNames: function () { return [ + this.$t('Settings.Theme Settings.Base Theme.System Default'), this.$t('Settings.Theme Settings.Base Theme.Light'), this.$t('Settings.Theme Settings.Base Theme.Dark'), - this.$t('Settings.Theme Settings.Base Theme.System'), this.$t('Settings.Theme Settings.Base Theme.Black'), this.$t('Settings.Theme Settings.Base Theme.Dracula') ] diff --git a/static/locales/en-US.yaml b/static/locales/en-US.yaml index 708dfcb64d8cc..94240baf53281 100644 --- a/static/locales/en-US.yaml +++ b/static/locales/en-US.yaml @@ -163,7 +163,7 @@ Settings: Base Theme: Base Theme Black: Black Dark: Dark - System: System + System Default: System Default Light: Light Dracula: Dracula Main Color Theme: diff --git a/static/locales/en_GB.yaml b/static/locales/en_GB.yaml index 3ea3ff2cceae5..fdaea70016597 100644 --- a/static/locales/en_GB.yaml +++ b/static/locales/en_GB.yaml @@ -158,7 +158,7 @@ Settings: Base Theme: 'Base theme' Black: 'Black' Dark: 'Dark' - System: 'System' + System Default: 'System Default' Light: 'Light' Dracula: 'Dracula' Main Color Theme: From 774eb0c2875fae1aba3ee54df7851dad6257f300 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sun, 10 Oct 2021 17:00:16 +0300 Subject: [PATCH 11/29] Use system default for deciding background color of newWindow --- src/main/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index 83d9cde26eddc..a017a3a2c5b4d 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -176,7 +176,8 @@ function runApp() { * Initial window options */ const commonBrowserWindowOptions = { - backgroundColor: '#212121', + // We respect system defaults first, before checking for user-preferences + backgroundColor: nativeTheme.shouldUseDarkColors ? '#f1f1f1' : '#f1f1f1', darkTheme: nativeTheme.shouldUseDarkColors, icon: isDev ? path.join(__dirname, '../../_icons/iconColor.png') From 025998fcea0d38aca1092eff7cb826dc0806ae04 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sun, 10 Oct 2021 23:50:12 +0300 Subject: [PATCH 12/29] Add baseTheme to state persistance --- src/renderer/components/theme-settings/theme-settings.js | 4 +++- src/renderer/components/theme-settings/theme-settings.vue | 2 +- src/renderer/store/modules/settings.js | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/theme-settings/theme-settings.js b/src/renderer/components/theme-settings/theme-settings.js index 109bbe3980e9e..a4df3f717d7e3 100644 --- a/src/renderer/components/theme-settings/theme-settings.js +++ b/src/renderer/components/theme-settings/theme-settings.js @@ -142,7 +142,7 @@ export default Vue.extend({ this.disableSmoothScrollingToggleValue = this.disableSmoothScrolling }, methods: { - updateBaseTheme: function (theme) { + updateTheme: function (theme) { const mainColor = `main${this.currentMainColor}` const secColor = `sec${this.currentSecColor}` @@ -152,6 +152,7 @@ export default Vue.extend({ secColor: secColor } + this.updateBaseTheme(theme) this.$parent.$parent.updateTheme(payload) this.currentBaseTheme = theme }, @@ -218,6 +219,7 @@ export default Vue.extend({ ...mapActions([ 'updateBarColor', + 'updateBaseTheme', 'updateUiScale', 'updateDisableSmoothScrolling', 'updateHideLabelsSideBar' diff --git a/src/renderer/components/theme-settings/theme-settings.vue b/src/renderer/components/theme-settings/theme-settings.vue index 2b5082fbf08f3..28bf1090a04df 100644 --- a/src/renderer/components/theme-settings/theme-settings.vue +++ b/src/renderer/components/theme-settings/theme-settings.vue @@ -46,7 +46,7 @@ :value="currentBaseTheme" :select-names="baseThemeNames" :select-values="baseThemeValues" - @change="updateBaseTheme" + @change="updateTheme" /> Date: Sun, 10 Oct 2021 23:50:25 +0300 Subject: [PATCH 13/29] Use baseTheme on browserWindow creation --- src/main/index.js | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/main/index.js b/src/main/index.js index a017a3a2c5b4d..422fc1783e007 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -176,7 +176,7 @@ function runApp() { * Initial window options */ const commonBrowserWindowOptions = { - // We respect system defaults first, before checking for user-preferences + // Respect system defaults first, before checking for user-preferences backgroundColor: nativeTheme.shouldUseDarkColors ? '#f1f1f1' : '#f1f1f1', darkTheme: nativeTheme.shouldUseDarkColors, icon: isDev @@ -230,7 +230,35 @@ function runApp() { height: 800 }) +<<<<<<< HEAD const boundsDoc = await baseHandlers.settings._findBounds() +======= + await settingsDb.findOne({'_id': 'baseTheme'}).then(({ value }) => { + switch (value) { + case 'system': + newWindow.setBackgroundColor( + nativeTheme.shouldUseDarkColors ? '#212121' : '#f1f1f1' + ) + break + case 'dark': + newWindow.setBackgroundColor('#212121') + break + case 'light': + newWindow.setBackgroundColor('#f1f1f1') + break + case 'black': + newWindow.setBackgroundColor('#000') + break + case 'dracula': + newWindow.setBackgroundColor('#282a36') + break + } + }).catch((error) => { + // Stick with the system default in the case we cannot find baseTheme + }) + + const boundsDoc = await settingsDb.findOne({ _id: 'bounds' }) +>>>>>>> ab1e0dae (Use baseTheme on browserWindow creation) if (typeof boundsDoc?.value === 'object') { const { maximized, ...bounds } = boundsDoc.value const allDisplaysSummaryWidth = screen From 24aa3282e250586ab0b10bc3f6ee2730323d55a4 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sun, 10 Oct 2021 23:56:08 +0300 Subject: [PATCH 14/29] Fix lint errors --- src/main/index.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 422fc1783e007..de89808e481ba 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -230,10 +230,8 @@ function runApp() { height: 800 }) -<<<<<<< HEAD const boundsDoc = await baseHandlers.settings._findBounds() -======= - await settingsDb.findOne({'_id': 'baseTheme'}).then(({ value }) => { + await settingsDb.findOne({ _id: 'baseTheme' }).then(({ value }) => { switch (value) { case 'system': newWindow.setBackgroundColor( @@ -253,12 +251,9 @@ function runApp() { newWindow.setBackgroundColor('#282a36') break } - }).catch((error) => { - // Stick with the system default in the case we cannot find baseTheme }) const boundsDoc = await settingsDb.findOne({ _id: 'bounds' }) ->>>>>>> ab1e0dae (Use baseTheme on browserWindow creation) if (typeof boundsDoc?.value === 'object') { const { maximized, ...bounds } = boundsDoc.value const allDisplaysSummaryWidth = screen @@ -367,17 +362,13 @@ function runApp() { app.quit() }) -<<<<<<< HEAD - ipcMain.on(IpcChannels.ENABLE_PROXY, (_, url) => { -======= nativeTheme.on('updated', () => { if (mainWindow) { mainWindow.webContents.send('native-theme-update', nativeTheme.shouldUseDarkColors) } }) - - ipcMain.on('enableProxy', (_, url) => { ->>>>>>> 4b5a72ae (Move to using main process messaging for theme change) + + ipcMain.on(IpcChannels.ENABLE_PROXY, (_, url) => { console.log(url) session.defaultSession.setProxy({ proxyRules: url From d65c2c31071213beee6175f4b449e7a2cae22bb1 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Thu, 14 Oct 2021 09:47:42 +0300 Subject: [PATCH 15/29] Improve window background logic --- src/main/index.js | 42 ++++++++----------- src/renderer/App.js | 7 +++- .../theme-settings/theme-settings.js | 2 +- .../theme-settings/theme-settings.vue | 2 +- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index de89808e481ba..39caaaa00191b 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -172,12 +172,27 @@ function runApp() { } async function createWindow(replaceMainWindow = true) { + const windowBackground = await settingsDb.findOne({ _id: 'baseTheme' }).then(({ value }) => { + switch (value) { + case 'dark': + return '#212121' + case 'light': + return '#f1f1f1' + case 'black': + return '#000' + case 'dracula': + return '#282a36' + case 'system': + default: + return nativeTheme.shouldUseDarkColors ? '#212121' : '#f1f1f1' + } + }) + /** * Initial window options */ const commonBrowserWindowOptions = { - // Respect system defaults first, before checking for user-preferences - backgroundColor: nativeTheme.shouldUseDarkColors ? '#f1f1f1' : '#f1f1f1', + backgroundColor: windowBackground, darkTheme: nativeTheme.shouldUseDarkColors, icon: isDev ? path.join(__dirname, '../../_icons/iconColor.png') @@ -230,29 +245,6 @@ function runApp() { height: 800 }) - const boundsDoc = await baseHandlers.settings._findBounds() - await settingsDb.findOne({ _id: 'baseTheme' }).then(({ value }) => { - switch (value) { - case 'system': - newWindow.setBackgroundColor( - nativeTheme.shouldUseDarkColors ? '#212121' : '#f1f1f1' - ) - break - case 'dark': - newWindow.setBackgroundColor('#212121') - break - case 'light': - newWindow.setBackgroundColor('#f1f1f1') - break - case 'black': - newWindow.setBackgroundColor('#000') - break - case 'dracula': - newWindow.setBackgroundColor('#282a36') - break - } - }) - const boundsDoc = await settingsDb.findOne({ _id: 'bounds' }) if (typeof boundsDoc?.value === 'object') { const { maximized, ...bounds } = boundsDoc.value diff --git a/src/renderer/App.js b/src/renderer/App.js index 3208ab4f37e7b..57851262d7f54 100644 --- a/src/renderer/App.js +++ b/src/renderer/App.js @@ -122,7 +122,7 @@ export default Vue.extend({ } }, created () { - this.setBodytheme() + this.setBodyTheme() this.checkThemeSettings() this.setWindowTitle() }, @@ -162,7 +162,7 @@ export default Vue.extend({ }) }, methods: { - setBodytheme: function () { + setBodyTheme: function () { if (window.matchMedia('(prefers-color-scheme: dark)').matches) { document.body.dataset.theme = 'dark' } else { @@ -175,6 +175,7 @@ export default Vue.extend({ let mainColor = localStorage.getItem('mainColor') let secColor = localStorage.getItem('secColor') + console.log(baseTheme) if (baseTheme === null) { baseTheme = 'dark' } @@ -204,6 +205,8 @@ export default Vue.extend({ localStorage.setItem('baseTheme', theme.baseTheme) localStorage.setItem('mainColor', theme.mainColor) localStorage.setItem('secColor', theme.secColor) + + console.log(localStorage.getItem('baseTheme')) }, checkForNewUpdates: function () { diff --git a/src/renderer/components/theme-settings/theme-settings.js b/src/renderer/components/theme-settings/theme-settings.js index a4df3f717d7e3..8d5bedfd08f1d 100644 --- a/src/renderer/components/theme-settings/theme-settings.js +++ b/src/renderer/components/theme-settings/theme-settings.js @@ -142,7 +142,7 @@ export default Vue.extend({ this.disableSmoothScrollingToggleValue = this.disableSmoothScrolling }, methods: { - updateTheme: function (theme) { + handleUpdateTheme: function (theme) { const mainColor = `main${this.currentMainColor}` const secColor = `sec${this.currentSecColor}` diff --git a/src/renderer/components/theme-settings/theme-settings.vue b/src/renderer/components/theme-settings/theme-settings.vue index 28bf1090a04df..b767e09ab2a66 100644 --- a/src/renderer/components/theme-settings/theme-settings.vue +++ b/src/renderer/components/theme-settings/theme-settings.vue @@ -46,7 +46,7 @@ :value="currentBaseTheme" :select-names="baseThemeNames" :select-values="baseThemeValues" - @change="updateTheme" + @change="handleUpdateTheme" /> Date: Thu, 14 Oct 2021 10:45:23 +0300 Subject: [PATCH 16/29] Catch settingsDb errors --- src/main/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/index.js b/src/main/index.js index 39caaaa00191b..456ce90b627ba 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -186,6 +186,9 @@ function runApp() { default: return nativeTheme.shouldUseDarkColors ? '#212121' : '#f1f1f1' } + }).catch((error) => { + // Default to nativeTheme settings if nothing is found. + return nativeTheme.shouldUseDarkColors ? '#212121' : '#f1f1f1' }) /** From b2af0f5193ed0bc6a63baa6eb11f9a09c057a057 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Thu, 14 Oct 2021 11:07:56 +0300 Subject: [PATCH 17/29] Remove dark flash on light themes --- src/index.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ejs b/src/index.ejs index 11d81f7d19926..a8d1de0293307 100644 --- a/src/index.ejs +++ b/src/index.ejs @@ -16,7 +16,7 @@ <% } %> - +