From bac19670f7fa5401fd22539cc68da600edf4b5fa Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 24 Feb 2026 21:16:38 +0200 Subject: [PATCH] some initial work on local only config --- .../settings_modal/helpers/setting.js | 44 ++++++++++++++----- src/stores/local_config.js | 16 ++++++- 2 files changed, 47 insertions(+), 13 deletions(-) diff --git a/src/components/settings_modal/helpers/setting.js b/src/components/settings_modal/helpers/setting.js index cb9bb0466..a064e10f4 100644 --- a/src/components/settings_modal/helpers/setting.js +++ b/src/components/settings_modal/helpers/setting.js @@ -47,6 +47,10 @@ export default { type: Boolean, default: false, }, + local: { + type: Boolean, + default: false, + }, parentPath: { type: [String, Array], }, @@ -259,11 +263,17 @@ export default { const writePath = `simple.${readPath}` if (!this.timedApplyMode) { - useSyncConfigStore().setSimplePrefAndSave({ - path: writePath, - value, - }) - useSyncConfigStore().pushSyncConfig() + if (this.local) { + useLocalConfigStore().set({ + path: writePath, + value, + }) + } else { + useSyncConfigStore().setSimplePrefAndSave({ + path: writePath, + value, + }) + } } else { if (useInterfaceStore().temporaryChangesTimeoutId !== null) { console.error("Can't track more than one temporary change") @@ -272,18 +282,30 @@ export default { const oldValue = get(this.configSource, readPath) - useSyncConfigStore().setPreference({ path: writePath, value }) + if (this.local) { + useLocalConfigStore().setTemporarily({ path: writePath, value }) + } else { + useSyncConfigStore().setPreference({ path: writePath, value }) + } const confirm = () => { - useSyncConfigStore().pushSyncConfig() + if (this.local) { + useLocalConfigStore().set({ path: writePath, value }) + } else { + useSyncConfigStore().pushSyncConfig() + } useInterfaceStore().clearTemporaryChanges() } const revert = () => { - useSyncConfigStore().setPreference({ - path: writePath, - value: oldValue, - }) + if (this.local) { + useLocalConfigStore().unsetTemporarily({ path: writePath, value }) + } else { + useSyncConfigStore().setPreference({ + path: writePath, + value: oldValue, + }) + } useInterfaceStore().clearTemporaryChanges() } diff --git a/src/stores/local_config.js b/src/stores/local_config.js index 208ae09cf..7b2c5f650 100644 --- a/src/stores/local_config.js +++ b/src/stores/local_config.js @@ -10,6 +10,9 @@ export const defaultState = { prefsStorage: { ...configDefaultState, }, + tempStorage: { + ...configDefaultState + } } export const useLocalConfigStore = defineStore('local_config', { @@ -20,6 +23,12 @@ export const useLocalConfigStore = defineStore('local_config', { set({ path, value }) { set(this.prefsStorage, path, value) }, + setTemporarily({ path, value }) { + set(this.tempStorage, path, value) + }, + unsetTemporarily({ path, value }) { + set(this.tempStorage, path, undefined) + }, unset({ path, value }) { set(this.prefsStorage, path, undefined) }, @@ -36,7 +45,7 @@ export const useLocalConfigStore = defineStore('local_config', { const result = Object.fromEntries( Object.entries(state.prefsStorage).map(([k, v]) => [ k, - v ?? instancePrefs[k], + state.tempStorage[k] ?? v ?? instancePrefs[k], ]), ) return result @@ -44,7 +53,10 @@ export const useLocalConfigStore = defineStore('local_config', { }, persist: { afterLoad(state) { - return state + return { + prefStorage: state.prefsStorage, + tempStorage: { ...configDefaultState }, + } }, }, })