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.
This commit is contained in:
Svallinn 2021-06-11 02:38:19 +01:00
parent 55a25dc1ea
commit b26e8b68ef
No known key found for this signature in database
GPG Key ID: 09FB527F34037CCA
1 changed files with 3 additions and 23 deletions

View File

@ -261,7 +261,7 @@ Object.assign(customGetters, {
/**********/ /**********/
const customActions = { const customActions = {
grabUserSettings: ({ commit, getters }) => { grabUserSettings: ({ commit, dispatch, getters }) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
settingsDb.find( settingsDb.find(
{ _id: { $ne: 'bounds' } }, { _id: { $ne: 'bounds' } },
@ -271,30 +271,10 @@ const customActions = {
return 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) { for (const setting of userSettings) {
const { _id, value } = setting const { _id, value } = setting
if (specialSettings.has(_id)) { if (getters.settingHasSideEffects(_id)) {
const specialSettingHandler = specialSettings.get(_id) dispatch(defaultSideEffectsTriggerId(_id), value)
specialSettingHandler(value)
continue
} }
commit(defaultMutationId(_id), value) commit(defaultMutationId(_id), value)