fix rouge local configs overriding sync config
This commit is contained in:
parent
2ab1d86d92
commit
e202f18720
6 changed files with 48 additions and 36 deletions
|
|
@ -654,6 +654,21 @@ export const LOCAL_DEFAULT_CONFIG = convertDefinitions(
|
||||||
|
|
||||||
export const LOCAL_ONLY_KEYS = new Set(Object.keys(LOCAL_DEFAULT_CONFIG))
|
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 = {
|
export const THEME_CONFIG_DEFINITIONS = {
|
||||||
theme: {
|
theme: {
|
||||||
description: 'Very old theme store, stores preset name, still in use',
|
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
|
/// For properties with special processing or properties that does not
|
||||||
/// make sense to be overriden on a instance-wide level.
|
/// 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
|
// Set these to undefined so it does not interfere with default settings check
|
||||||
...makeUndefined(INSTANCE_DEFAULT_CONFIG),
|
...INSTANCE_DEFAULT_CONFIG,
|
||||||
...makeUndefined(LOCAL_DEFAULT_CONFIG),
|
...LOCAL_DEFAULT_CONFIG,
|
||||||
...makeUndefined(THEME_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 = ({
|
export const validateSetting = ({
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { getEngineChecksum, init } from '../theme_data/theme_data_3.service.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_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
|
// On platforms where this is not supported, it will return undefined
|
||||||
// Otherwise it will return an array
|
// Otherwise it will return an array
|
||||||
|
|
@ -268,7 +268,7 @@ const extractStyleConfig = ({
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultStyleConfig = extractStyleConfig(defaultState)
|
const defaultStyleConfig = extractStyleConfig(ROOT_CONFIG)
|
||||||
|
|
||||||
export const applyStyleConfig = (input) => {
|
export const applyStyleConfig = (input) => {
|
||||||
const config = extractStyleConfig(input)
|
const config = extractStyleConfig(input)
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,15 @@ import {
|
||||||
LOCAL_DEFAULT_CONFIG,
|
LOCAL_DEFAULT_CONFIG,
|
||||||
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
|
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
|
||||||
validateSetting,
|
validateSetting,
|
||||||
|
makeUndefined,
|
||||||
} from 'src/modules/default_config_state'
|
} from 'src/modules/default_config_state'
|
||||||
|
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
prefsStorage: {
|
prefsStorage: {
|
||||||
...LOCAL_DEFAULT_CONFIG,
|
...makeUndefined(LOCAL_DEFAULT_CONFIG),
|
||||||
},
|
},
|
||||||
tempStorage: {
|
tempStorage: {
|
||||||
...LOCAL_DEFAULT_CONFIG,
|
...makeUndefined(LOCAL_DEFAULT_CONFIG),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,8 +57,8 @@ export const useLocalConfigStore = defineStore('local_config', {
|
||||||
persist: {
|
persist: {
|
||||||
afterLoad(state) {
|
afterLoad(state) {
|
||||||
return {
|
return {
|
||||||
prefsStorage: state.prefsStorage ?? { ...LOCAL_DEFAULT_CONFIG },
|
prefsStorage: state.prefsStorage ?? { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
|
||||||
tempStorage: { ...LOCAL_DEFAULT_CONFIG },
|
tempStorage: { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,13 @@ export const useMergedConfigStore = defineStore('merged_config', {
|
||||||
const localPrefs = useLocalConfigStore().prefsStorage
|
const localPrefs = useLocalConfigStore().prefsStorage
|
||||||
const syncPrefs = useSyncConfigStore().prefsStorage
|
const syncPrefs = useSyncConfigStore().prefsStorage
|
||||||
|
|
||||||
const getValue = (k) =>
|
const getValue = (k) => {
|
||||||
tempPrefs[k] ?? localPrefs[k] ?? syncPrefs.simple[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 getDefault = (k) => instancePrefs[k] ?? ROOT_CONFIG[k]
|
||||||
|
|
||||||
const result = Object.fromEntries(
|
const result = Object.fromEntries(
|
||||||
|
|
|
||||||
|
|
@ -24,29 +24,13 @@ import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
|
|
||||||
import { storage } from 'src/lib/storage.js'
|
import { storage } from 'src/lib/storage.js'
|
||||||
import {
|
import {
|
||||||
defaultState as configDefaultState,
|
ROOT_CONFIG,
|
||||||
INSTANCE_DEFAULT_CONFIG,
|
ROOT_CONFIG_DEFINITIONS,
|
||||||
INSTANCE_DEFAULT_CONFIG_DEFINITIONS,
|
|
||||||
LOCAL_DEFAULT_CONFIG,
|
|
||||||
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
|
|
||||||
THEME_CONFIG,
|
|
||||||
THEME_CONFIG_DEFINITIONS,
|
|
||||||
validateSetting,
|
validateSetting,
|
||||||
|
makeUndefined,
|
||||||
} from 'src/modules/default_config_state.js'
|
} from 'src/modules/default_config_state.js'
|
||||||
import { oldDefaultConfigSync } from 'src/modules/old_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 VERSION = 2
|
||||||
export const NEW_USER_DATE = new Date('2026-03-16') // date of writing this, basically
|
export const NEW_USER_DATE = new Date('2026-03-16') // date of writing this, basically
|
||||||
|
|
||||||
|
|
@ -69,11 +53,9 @@ export const defaultState = {
|
||||||
prefsStorage: {
|
prefsStorage: {
|
||||||
_journal: [],
|
_journal: [],
|
||||||
simple: {
|
simple: {
|
||||||
dontShowUpdateNotifs: false,
|
|
||||||
collapseNav: false,
|
|
||||||
muteFilters: {},
|
muteFilters: {},
|
||||||
|
|
||||||
...configDefaultState,
|
...makeUndefined({ ...ROOT_CONFIG }),
|
||||||
},
|
},
|
||||||
collections: {
|
collections: {
|
||||||
pinnedStatusActions: ['reply', 'retweet', 'favorite', 'emoji'],
|
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({
|
const finalValue = validateSetting({
|
||||||
path: path.split('.')[1],
|
path: path.split('.')[1],
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ import { defineStore } from 'pinia'
|
||||||
import { toRaw } from 'vue'
|
import { toRaw } from 'vue'
|
||||||
|
|
||||||
import { storage } from 'src/lib/storage.js'
|
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
|
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue