diff --git a/src/modules/default_config_state.js b/src/modules/default_config_state.js index e73da81a4..4cbef77f6 100644 --- a/src/modules/default_config_state.js +++ b/src/modules/default_config_state.js @@ -654,6 +654,46 @@ export const LOCAL_DEFAULT_CONFIG = convertDefinitions( export const LOCAL_ONLY_KEYS = new Set(Object.keys(LOCAL_DEFAULT_CONFIG)) +export const THEME_CONFIG_DEFINITIONS = { + theme: { + description: 'Very old theme store, stores preset name, still in use', + default: null, + }, + colors: { + description: 'VERY old theme store, just colors of V1, probably not even used anymore', + default: {}, + }, + // V2 + customTheme: { + description: '"Snapshot", previously was used as actual theme store for V2 so it\'s still used in case of PleromaFE downgrade event.', + default: null, + }, + customThemeSource: { + description: '"Source", stores original theme data', + default: null, + }, + // V3 + style: { + description: 'Style name for builtins', + default: null, + }, + styleCustomData: { + description: 'Custom style data (i.e. not builtin)', + default: null, + }, + palette: { + description: 'Palette name for builtins', + default: null, + }, + paletteCustomData: { + description: 'Custom palette data (i.e. not builtin)', + default: null, + }, +} +export const THEME_CONFIG = convertDefinitions( + THEME_CONFIG_DEFINITIONS, +) + export const makeUndefined = (c) => Object.fromEntries(Object.keys(c).map((key) => [key, undefined])) @@ -663,25 +703,7 @@ export const defaultState = { // Set these to undefined so it does not interfere with default settings check ...makeUndefined(INSTANCE_DEFAULT_CONFIG), ...makeUndefined(LOCAL_DEFAULT_CONFIG), - // If there are any configurations that does not make sense to - // have instance-wide default, put it here and explain why. - - // # Special processing - // ## Theme stuff - theme: undefined, // Very old theme store, stores preset name, still in use - - // V1 - colors: {}, // VERY old theme store, just colors of V1, probably not even used anymore - - // V2 - customTheme: undefined, // "snapshot", previously was used as actual theme store for V2 so it's still used in case of PleromaFE downgrade event. - customThemeSource: undefined, // "source", stores original theme data - - // V3 - style: null, - styleCustomData: null, - palette: null, - paletteCustomData: null, + ...makeUndefined(THEME_CONFIG), } export const validateSetting = ({ diff --git a/src/stores/merged_config.js b/src/stores/merged_config.js index e28d79748..0639b3b1a 100644 --- a/src/stores/merged_config.js +++ b/src/stores/merged_config.js @@ -7,12 +7,14 @@ import { useSyncConfigStore } from 'src/stores/sync_config.js' import { INSTANCE_DEFAULT_CONFIG, LOCAL_DEFAULT_CONFIG, + THEME_CONFIG, LOCAL_ONLY_KEYS, } from 'src/modules/default_config_state.js' const ROOT_CONFIG = { ...INSTANCE_DEFAULT_CONFIG, ...LOCAL_DEFAULT_CONFIG, + ...THEME_CONFIG, } export const useMergedConfigStore = defineStore('merged_config', { diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 4b32b4f89..064d3f1ff 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -28,11 +28,25 @@ import { INSTANCE_DEFAULT_CONFIG, INSTANCE_DEFAULT_CONFIG_DEFINITIONS, LOCAL_DEFAULT_CONFIG, - LOCAL_ONLY_KEYS, + LOCAL_DEFAULT_CONFIG_DEFINITIONS, + THEME_CONFIG, + THEME_CONFIG_DEFINITIONS, validateSetting, } 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 @@ -491,14 +505,14 @@ export const useSyncConfigStore = defineStore('sync_config', { ) } - const definition = INSTANCE_DEFAULT_CONFIG_DEFINITIONS[path.split('.')[1]] + const definition = ROOT_CONFIG_DEFINITIONS[path.split('.')[1]] const finalValue = validateSetting({ path: path.split('.')[1], value, definition, throwError: false, - defaultState: INSTANCE_DEFAULT_CONFIG, + defaultState: ROOT_CONFIG, }) set(this.prefsStorage, path, finalValue)