Store/Settings: Propagate side effects to other existing windows
When syncing a setting between windows, if that setting has any side effects, a trigger is fired in all other windows to perform those side effects in their own environment.
This commit is contained in:
parent
b26e8b68ef
commit
b6bd3e6434
|
@ -286,11 +286,20 @@ const customActions = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
setUpListenerToSyncSettings: ({ commit, getters }) => {
|
setUpListenerToSyncSettings: ({ commit, dispatch, getters }) => {
|
||||||
if (getters.getUsingElectron) {
|
const {
|
||||||
|
getUsingElectron: usingElectron,
|
||||||
|
settingHasSideEffects
|
||||||
|
} = getters
|
||||||
|
|
||||||
|
if (usingElectron) {
|
||||||
const { ipcRenderer } = require('electron')
|
const { ipcRenderer } = require('electron')
|
||||||
ipcRenderer.on('syncSetting', (_, setting) => {
|
ipcRenderer.on('syncSetting', (_, setting) => {
|
||||||
const { _id, value } = setting
|
const { _id, value } = setting
|
||||||
|
if (settingHasSideEffects(_id)) {
|
||||||
|
dispatch(defaultSideEffectsTriggerId(_id), value)
|
||||||
|
}
|
||||||
|
|
||||||
commit(defaultMutationId(_id), value)
|
commit(defaultMutationId(_id), value)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue