diff --git a/src/application/worker/index.worker.js b/src/application/worker/index.worker.js index a07b7f768..96bcd6c36 100644 --- a/src/application/worker/index.worker.js +++ b/src/application/worker/index.worker.js @@ -341,13 +341,9 @@ async function start() { } } - store.commit("groups/SWAP", {}); - store.commit("modules/SWAP", {}); - store.commit("inputs/SWAP", {}); - - store.commit("groups/CLEAR_SWAP", {}); - store.commit("modules/CLEAR_SWAP", {}); - store.commit("inputs/CLEAR_SWAP", {}); + store.commit("groups/SWAP"); + store.commit("modules/SWAP"); + store.commit("inputs/SWAP"); return; } diff --git a/src/application/worker/store/modules/groups.js b/src/application/worker/store/modules/groups.js index 5238acbb0..ae2234ec3 100644 --- a/src/application/worker/store/modules/groups.js +++ b/src/application/worker/store/modules/groups.js @@ -79,8 +79,12 @@ import { applyExpression } from "../../../utils/apply-expression"; * }; */ -const state = { groups: [] }; -const swap = { groups: [] }; +function getDefaultState() { + return { groups: [] }; +} + +const state = getDefaultState(); +const swap = getDefaultState(); // Any keys marked false or arrays with keys given // will not be moved from the base state when swapped @@ -358,7 +362,7 @@ const mutations = { } }, - SWAP: SWAP(swap, () => ({ groups: [] }), sharedPropertyRestrictions) + SWAP: SWAP(swap, getDefaultState, sharedPropertyRestrictions) }; export default { diff --git a/src/application/worker/store/modules/modules.js b/src/application/worker/store/modules/modules.js index cb16effa6..fb42a8162 100644 --- a/src/application/worker/store/modules/modules.js +++ b/src/application/worker/store/modules/modules.js @@ -24,19 +24,17 @@ const sharedPropertyRestrictions = { metaQueue: true // will move }; -const state = { - registered: {}, - active: {}, - propQueue: {}, - metaQueue: {} -}; +function getDefaultState() { + return { + registered: {}, + active: {}, + propQueue: {}, + metaQueue: {} + }; +} -const swap = { - registered: {}, - active: {}, - propQueue: {}, - metaQueue: {} -}; +const state = getDefaultState(); +const swap = getDefaultState(); // this function either creates module properties from an existing module // (e.g. loading a preset) or initialises the default value @@ -721,7 +719,7 @@ const mutations = { } }, - SWAP: SWAP(swap, () => ({}), sharedPropertyRestrictions) + SWAP: SWAP(swap, getDefaultState, sharedPropertyRestrictions) }; export default {