From b6bd3e64343eef5b30725c06707d49607cfc0c7b Mon Sep 17 00:00:00 2001 From: Svallinn <41585298+Svallinn@users.noreply.github.com> Date: Fri, 11 Jun 2021 02:44:47 +0100 Subject: [PATCH] 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. --- src/renderer/store/modules/settings.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 5fdd5cc7..9825930a 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -286,11 +286,20 @@ const customActions = { }) }, - setUpListenerToSyncSettings: ({ commit, getters }) => { - if (getters.getUsingElectron) { + setUpListenerToSyncSettings: ({ commit, dispatch, getters }) => { + const { + getUsingElectron: usingElectron, + settingHasSideEffects + } = getters + + if (usingElectron) { const { ipcRenderer } = require('electron') ipcRenderer.on('syncSetting', (_, setting) => { const { _id, value } = setting + if (settingHasSideEffects(_id)) { + dispatch(defaultSideEffectsTriggerId(_id), value) + } + commit(defaultMutationId(_id), value) }) }