From b0f973b76ac7ca5b991caf72a96c46f4df0129cb Mon Sep 17 00:00:00 2001 From: Svallinn <41585298+Svallinn@users.noreply.github.com> Date: Fri, 11 Jun 2021 02:22:59 +0100 Subject: [PATCH] Store/Settings: Handle `uiScale`'s side effects in the module --- .../components/theme-settings/theme-settings.js | 8 -------- .../components/theme-settings/theme-settings.vue | 2 +- src/renderer/store/modules/settings.js | 14 ++++++++------ 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/renderer/components/theme-settings/theme-settings.js b/src/renderer/components/theme-settings/theme-settings.js index 6b12ec76..45e01f5f 100644 --- a/src/renderer/components/theme-settings/theme-settings.js +++ b/src/renderer/components/theme-settings/theme-settings.js @@ -145,14 +145,6 @@ export default Vue.extend({ localStorage.setItem('expandSideBar', value) }, - handleUiScale: function (value) { - // FIXME: No electron safeguard - const { webFrame } = require('electron') - const zoomFactor = value / 100 - webFrame.setZoomFactor(zoomFactor) - this.updateUiScale(parseInt(value)) - }, - handleRestartPrompt: function (value) { this.disableSmoothScrollingToggleValue = value this.showRestartPrompt = true diff --git a/src/renderer/components/theme-settings/theme-settings.vue b/src/renderer/components/theme-settings/theme-settings.vue index 078056e4..1e7fde7e 100644 --- a/src/renderer/components/theme-settings/theme-settings.vue +++ b/src/renderer/components/theme-settings/theme-settings.vue @@ -30,7 +30,7 @@ :max-value="maxUiScale" :step="uiScaleStep" value-extension="%" - @change="handleUiScale" + @change="updateUiScale(parseInt($event))" />
diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 049d6bd7..12fc7612 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -159,7 +159,6 @@ const defaultSideEffectsTriggerId = settingId => const state = { currentTheme: 'lightRed', - uiScale: 100, backendFallback: true, checkForUpdates: true, checkForBlogPosts: true, @@ -214,12 +213,15 @@ const state = { } const stateWithSideEffects = { - /* - setting: { - defaultValue: any, - sideEffectsHandler: (store, settingValue) => void + uiScale: { + defaultValue: 100, + sideEffectsHandler: ({ state: { usingElectron } }, value) => { + if (usingElectron) { + const { webFrame } = require('electron') + webFrame.setZoomFactor(value / 100) + } + } } - */ } const customState = {