Compare commits

..

No commits in common. "276caef91b8755cd9d485e3c0ce6dd72325837a9" and "8bffe9f0aa8c9cc3d561ac6b840510c4f12447cb" have entirely different histories.

2 changed files with 17 additions and 23 deletions

View file

@ -688,7 +688,7 @@ export const SYNC_DEFAULT_CONFIG_DEFINITIONS = {
description: 'Object containing mute filters',
type: 'object',
default: {},
},
}
}
export const SYNC_DEFAULT_CONFIG = convertDefinitions(
SYNC_DEFAULT_CONFIG_DEFINITIONS,
@ -764,14 +764,8 @@ export const validateSetting = ({
validateObjects = true,
}) => {
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.`,
)
if (validateObjects && definition.type === 'object' && path.split('.').length <= 1) {
console.error(`attempt to set object ${fullPath} instead of its children. ignoring.`)
return undefined
}

View file

@ -777,21 +777,21 @@ export const useSyncConfigStore = defineStore('sync_config', {
afterLoad(state) {
console.debug('Validating persisted state of SyncConfig')
const newState = { ...state }
const newEntries = Object.entries(ROOT_CONFIG).map(([path, value]) => {
const definition = ROOT_CONFIG_DEFINITIONS[path]
const finalValue = validateSetting({
path,
value: newState.prefsStorage.simple[path],
definition,
throwError: false,
validateObjects: false,
defaultState: ROOT_CONFIG,
})
const newEntries = Object.entries(ROOT_CONFIG).map(
([path, value]) => {
const definition = ROOT_CONFIG_DEFINITIONS[path]
const finalValue = validateSetting({
path,
value: newState.prefsStorage.simple[path],
definition,
throwError: false,
validateObjects: false,
defaultState: ROOT_CONFIG,
})
return finalValue === undefined
? definition.default
: [path, finalValue]
})
return finalValue === undefined ? definition.default : [path, finalValue]
},
)
newState.prefsStorage.simple = Object.fromEntries(
newEntries.filter((_) => _),
)