fix rouge local configs overriding sync config

This commit is contained in:
Henry Jameson 2026-03-25 11:41:42 +02:00
commit e202f18720
6 changed files with 48 additions and 36 deletions

View file

@ -654,6 +654,21 @@ export const LOCAL_DEFAULT_CONFIG = convertDefinitions(
export const LOCAL_ONLY_KEYS = new Set(Object.keys(LOCAL_DEFAULT_CONFIG))
export const SYNC_DEFAULT_CONFIG_DEFINITIONS = {
dontShowUpdateNotifs: {
description: 'Never show update notification (pleroma-tan)',
default: false,
},
collapseNav: {
description: 'Collapse navigation panel to header only',
default: false
}
}
export const SYNC_DEFAULT_CONFIG = convertDefinitions(
SYNC_DEFAULT_CONFIG_DEFINITIONS,
)
export const SYNC_ONLY_KEYS = new Set(Object.keys(SYNC_DEFAULT_CONFIG))
export const THEME_CONFIG_DEFINITIONS = {
theme: {
description: 'Very old theme store, stores preset name, still in use',
@ -699,11 +714,19 @@ export const makeUndefined = (c) =>
/// For properties with special processing or properties that does not
/// make sense to be overriden on a instance-wide level.
export const defaultState = {
export const ROOT_CONFIG = {
// Set these to undefined so it does not interfere with default settings check
...makeUndefined(INSTANCE_DEFAULT_CONFIG),
...makeUndefined(LOCAL_DEFAULT_CONFIG),
...makeUndefined(THEME_CONFIG),
...INSTANCE_DEFAULT_CONFIG,
...LOCAL_DEFAULT_CONFIG,
...SYNC_DEFAULT_CONFIG,
...THEME_CONFIG,
}
export const ROOT_CONFIG_DEFINITIONS = {
...INSTANCE_DEFAULT_CONFIG_DEFINITIONS,
...LOCAL_DEFAULT_CONFIG_DEFINITIONS,
...SYNC_DEFAULT_CONFIG_DEFINITIONS,
...THEME_CONFIG_DEFINITIONS,
}
export const validateSetting = ({

View file

@ -8,7 +8,7 @@ import { getEngineChecksum, init } from '../theme_data/theme_data_3.service.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { defaultState } from 'src/modules/default_config_state.js'
import { ROOT_CONFIG } from 'src/modules/default_config_state.js'
// On platforms where this is not supported, it will return undefined
// Otherwise it will return an array
@ -268,7 +268,7 @@ const extractStyleConfig = ({
return result
}
const defaultStyleConfig = extractStyleConfig(defaultState)
const defaultStyleConfig = extractStyleConfig(ROOT_CONFIG)
export const applyStyleConfig = (input) => {
const config = extractStyleConfig(input)

View file

@ -8,14 +8,15 @@ import {
LOCAL_DEFAULT_CONFIG,
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
validateSetting,
makeUndefined,
} from 'src/modules/default_config_state'
export const defaultState = {
prefsStorage: {
...LOCAL_DEFAULT_CONFIG,
...makeUndefined(LOCAL_DEFAULT_CONFIG),
},
tempStorage: {
...LOCAL_DEFAULT_CONFIG,
...makeUndefined(LOCAL_DEFAULT_CONFIG),
},
}
@ -56,8 +57,8 @@ export const useLocalConfigStore = defineStore('local_config', {
persist: {
afterLoad(state) {
return {
prefsStorage: state.prefsStorage ?? { ...LOCAL_DEFAULT_CONFIG },
tempStorage: { ...LOCAL_DEFAULT_CONFIG },
prefsStorage: state.prefsStorage ?? { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
tempStorage: { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
}
},
},

View file

@ -25,8 +25,13 @@ export const useMergedConfigStore = defineStore('merged_config', {
const localPrefs = useLocalConfigStore().prefsStorage
const syncPrefs = useSyncConfigStore().prefsStorage
const getValue = (k) =>
tempPrefs[k] ?? localPrefs[k] ?? syncPrefs.simple[k]
const getValue = (k) => {
if (LOCAL_ONLY_KEYS.has(k)) {
return tempPrefs[k] ?? localPrefs[k] ?? syncPrefs.simple[k]
} else {
return tempPrefs[k] ?? syncPrefs.simple[k]
}
}
const getDefault = (k) => instancePrefs[k] ?? ROOT_CONFIG[k]
const result = Object.fromEntries(

View file

@ -24,29 +24,13 @@ import { useLocalConfigStore } from 'src/stores/local_config.js'
import { storage } from 'src/lib/storage.js'
import {
defaultState as configDefaultState,
INSTANCE_DEFAULT_CONFIG,
INSTANCE_DEFAULT_CONFIG_DEFINITIONS,
LOCAL_DEFAULT_CONFIG,
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
THEME_CONFIG,
THEME_CONFIG_DEFINITIONS,
ROOT_CONFIG,
ROOT_CONFIG_DEFINITIONS,
validateSetting,
makeUndefined,
} from 'src/modules/default_config_state.js'
import { oldDefaultConfigSync } from 'src/modules/old_default_config_state.js'
const ROOT_CONFIG_DEFINITIONS = {
...INSTANCE_DEFAULT_CONFIG_DEFINITIONS,
...LOCAL_DEFAULT_CONFIG_DEFINITIONS,
...THEME_CONFIG_DEFINITIONS,
}
const ROOT_CONFIG = {
...INSTANCE_DEFAULT_CONFIG,
...LOCAL_DEFAULT_CONFIG,
...THEME_CONFIG,
}
export const VERSION = 2
export const NEW_USER_DATE = new Date('2026-03-16') // date of writing this, basically
@ -69,11 +53,9 @@ export const defaultState = {
prefsStorage: {
_journal: [],
simple: {
dontShowUpdateNotifs: false,
collapseNav: false,
muteFilters: {},
...configDefaultState,
...makeUndefined({ ...ROOT_CONFIG }),
},
collections: {
pinnedStatusActions: ['reply', 'retweet', 'favorite', 'emoji'],
@ -505,7 +487,9 @@ export const useSyncConfigStore = defineStore('sync_config', {
)
}
const definition = ROOT_CONFIG_DEFINITIONS[path.split('.')[1]]
const definition = path.startsWith('simple.muteFilters')
? { default: {} }
: ROOT_CONFIG_DEFINITIONS[path.split('.')[1]]
const finalValue = validateSetting({
path: path.split('.')[1],

View file

@ -15,7 +15,6 @@ import { defineStore } from 'pinia'
import { toRaw } from 'vue'
import { storage } from 'src/lib/storage.js'
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically