diff --git a/src/components/settings_modal/settings_modal.js b/src/components/settings_modal/settings_modal.js index ea1b56212..f889cc66f 100644 --- a/src/components/settings_modal/settings_modal.js +++ b/src/components/settings_modal/settings_modal.js @@ -11,6 +11,7 @@ import Popover from '../popover/popover.vue' import { useInterfaceStore } from 'src/stores/interface.js' import { useLocalConfigStore } from 'src/stores/local_config.js' import { useSyncConfigStore } from 'src/stores/sync_config.js' +import { useMergedConfigStore } from 'src/stores/merged_config.js' import { LOCAL_ONLY_KEYS } from 'src/modules/default_config_state.js' import { @@ -145,7 +146,7 @@ const SettingsModal = { } else { if (path.startsWith('muteFilters')) { Object.keys( - useSyncConfigStore().mergedConfig.muteFilters, + useMergedConfigStore().mergedConfig.muteFilters, ).forEach((key) => { useSyncConfigStore().unsetPreference({ path: `simple.${path}.${key}`, @@ -179,7 +180,7 @@ const SettingsModal = { this.dataThemeExporter.exportData() }, generateExport(theme = false) { - const config = useSyncConfigStore().mergedConfigWithoutDefaults + const config = useMergedConfigStore().mergedConfigWithoutDefaults let sample = config if (!theme) { const ignoreList = new Set([ @@ -223,7 +224,7 @@ const SettingsModal = { }), expertLevel: { get() { - return useSyncConfigStore().mergedConfig.expertLevel > 0 + return useMergedConfigStore().mergedConfig.expertLevel > 0 }, set(value) { useSyncConfigStore().setSimplePrefAndSave({ diff --git a/src/modules/default_config_state.js b/src/modules/default_config_state.js index 4cbef77f6..fd75701cf 100644 --- a/src/modules/default_config_state.js +++ b/src/modules/default_config_state.js @@ -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 = ({ diff --git a/src/services/style_setter/style_setter.js b/src/services/style_setter/style_setter.js index e3abb39c4..c8e90c0a6 100644 --- a/src/services/style_setter/style_setter.js +++ b/src/services/style_setter/style_setter.js @@ -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) diff --git a/src/stores/local_config.js b/src/stores/local_config.js index 6d52f94d2..f8b76a26c 100644 --- a/src/stores/local_config.js +++ b/src/stores/local_config.js @@ -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) }, } }, }, diff --git a/src/stores/merged_config.js b/src/stores/merged_config.js index 0639b3b1a..80d27fabf 100644 --- a/src/stores/merged_config.js +++ b/src/stores/merged_config.js @@ -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( diff --git a/src/stores/sync_config.js b/src/stores/sync_config.js index 064d3f1ff..a6580b5c7 100644 --- a/src/stores/sync_config.js +++ b/src/stores/sync_config.js @@ -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], diff --git a/src/stores/user_highlight.js b/src/stores/user_highlight.js index ae2bd4d4c..c70c7f57f 100644 --- a/src/stores/user_highlight.js +++ b/src/stores/user_highlight.js @@ -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