restructure settings definitions

This commit is contained in:
Henry Jameson 2026-03-24 20:04:46 +02:00
commit a461068e40
9 changed files with 432 additions and 139 deletions

View file

@ -4,14 +4,17 @@ import { toRaw } from 'vue'
import { useInstanceStore } from 'src/stores/instance'
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
import {
LOCAL_DEFAULT_CONFIG,
LOCAL_DEFAULT_CONFIG_DEFINITIONS
} from 'src/modules/default_config_state'
export const defaultState = {
prefsStorage: {
...configDefaultState,
...LOCAL_DEFAULT_CONFIG,
},
tempStorage: {
...configDefaultState,
...LOCAL_DEFAULT_CONFIG,
},
}
@ -21,7 +24,17 @@ export const useLocalConfigStore = defineStore('local_config', {
},
actions: {
set({ path, value }) {
set(this.prefsStorage, path, value)
const definition = LOCAL_DEFAULT_CONFIG_DEFINITIONS[path]
const finalValue = validateSetting({
path,
value,
definition,
throwError: false,
defaultState: LOCAL_DEFAULT_CONFIG,
})
set(this.prefsStorage, path, finalValue)
},
setTemporarily({ path, value }) {
set(this.tempStorage, path, value)