From b26e8b68ef73c105800d678372ea4ca096c9e256 Mon Sep 17 00:00:00 2001 From: Svallinn <41585298+Svallinn@users.noreply.github.com> Date: Fri, 11 Jun 2021 02:38:19 +0100 Subject: [PATCH] Store/Settings: Make `grabUserSettings` check for side effects globally Previously, a custom Map was provided to the function in order to determine whether or not a setting contained side effects that needed to be handled. That Map has now been deleted and the function has been modified to make use of the module's new architecture. --- src/renderer/store/modules/settings.js | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 8d47ed76..5fdd5cc7 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -261,7 +261,7 @@ Object.assign(customGetters, { /**********/ const customActions = { - grabUserSettings: ({ commit, getters }) => { + grabUserSettings: ({ commit, dispatch, getters }) => { return new Promise((resolve, reject) => { settingsDb.find( { _id: { $ne: 'bounds' } }, @@ -271,30 +271,10 @@ const customActions = { return } - const specialSettings = new Map([ - ['uiScale', - (value) => { - if (getters.getUsingElectron) { - const { webFrame } = require('electron') - webFrame.setZoomFactor(parseInt(value) / 100) - } - commit('setUiScale', value) - } - ], - ['defaultVolume', - (value) => { - sessionStorage.setItem('volume', value) - commit('setDefaultVolume', value) - } - ] - ]) - for (const setting of userSettings) { const { _id, value } = setting - if (specialSettings.has(_id)) { - const specialSettingHandler = specialSettings.get(_id) - specialSettingHandler(value) - continue + if (getters.settingHasSideEffects(_id)) { + dispatch(defaultSideEffectsTriggerId(_id), value) } commit(defaultMutationId(_id), value)