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:
parent
55a25dc1ea
commit
b26e8b68ef
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue