From 14e2e57c5536e73cd21b5f0e5a534cede106bbcd Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Fri, 10 Apr 2026 01:08:24 +0300 Subject: [PATCH] fix objects not loading/saved/verified --- src/modules/default_config_state.js | 38 ++++++++++++++++++++++++++--- src/stores/instance.js | 1 + src/stores/sync_config.js | 14 +++++------ 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/modules/default_config_state.js b/src/modules/default_config_state.js index ecd580577..ff43e4dee 100644 --- a/src/modules/default_config_state.js +++ b/src/modules/default_config_state.js @@ -531,6 +531,18 @@ export const INSTANCE_DEFAULT_CONFIG_DEFINITIONS = { type: 'string', required: false, }, + theme3hacks: { + description: 'Theme 3 hacks (need separation)', + type: 'object', + required: false, + default: {}, + }, + highlights: { + description: 'User highlights', + type: 'object', + required: false, + default: {}, + }, } export const INSTANCE_DEFAULT_CONFIG = convertDefinitions( INSTANCE_DEFAULT_CONFIG_DEFINITIONS, @@ -672,6 +684,11 @@ export const SYNC_DEFAULT_CONFIG_DEFINITIONS = { description: 'Collapse navigation panel to header only', default: false, }, + muteFilters: { + description: 'Object containing mute filters', + type: 'object', + default: {}, + } } export const SYNC_DEFAULT_CONFIG = convertDefinitions( SYNC_DEFAULT_CONFIG_DEFINITIONS, @@ -740,14 +757,27 @@ export const ROOT_CONFIG_DEFINITIONS = { export const validateSetting = ({ value, - path, + path: fullPath, definition, throwError, defaultState, + validateObjects = true, }) => { - if (value === undefined) return // only null is allowed as missing value - if (get(defaultState, path) === undefined) { - const string = `Unknown option ${path}, value: ${value}` + const path = fullPath.replace(/^simple./, '') + if (validateObjects && definition.type === 'object' && path.split('.').length <= 1) { + console.error(`attempt to set object ${fullPath} instead of its children. ignoring.`) + return undefined + } + + if (path.includes('muteFilters')) { + console.log('##', path, value, definition) + console.log(value) + console.log(path) + console.log('====') + } + if (value === undefined) return undefined // only null is allowed as missing value + if (get(defaultState, path.split('.')[0]) === undefined) { + const string = `Unknown option ${fullPath}, value: ${value}` if (throwError) { throw new Error(string) diff --git a/src/stores/instance.js b/src/stores/instance.js index 2923f3ad8..54b3cf43c 100644 --- a/src/stores/instance.js +++ b/src/stores/instance.js @@ -201,6 +201,7 @@ export const useInstanceStore = defineStore('instance', { definition, throwError: true, defaultState: DEFAULT_STATE, + validateObjects: false, }) set(this, path, finalValue) diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 063595509..bad0a1515 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -302,7 +302,7 @@ export const _mergePrefs = (recent, stale) => { : ROOT_CONFIG_DEFINITIONS[entry] const finalValue = validateSetting({ - path: entry, + path, value: args[0], definition, throwError: false, @@ -516,7 +516,7 @@ export const useSyncConfigStore = defineStore('sync_config', { : ROOT_CONFIG_DEFINITIONS[path.split('.')[1]] const finalValue = validateSetting({ - path: path.split('.')[1], + path, value, definition, throwError: false, @@ -777,21 +777,19 @@ export const useSyncConfigStore = defineStore('sync_config', { afterLoad(state) { console.debug('Validating persisted state of SyncConfig') const newState = { ...state } - const newEntries = Object.entries(newState.prefsStorage.simple).map( + const newEntries = Object.entries(ROOT_CONFIG).map( ([path, value]) => { - if (path === 'muteFilters') { - return value - } const definition = ROOT_CONFIG_DEFINITIONS[path] const finalValue = validateSetting({ path, - value, + value: newState.prefsStorage.simple[path], definition, throwError: false, + validateObjects: false, defaultState: ROOT_CONFIG, }) - return finalValue === undefined ? undefined : [path, finalValue] + return finalValue === undefined ? definition.default : [path, finalValue] }, ) newState.prefsStorage.simple = Object.fromEntries(