Merge branch 'setttingssync' into shigusegubu-themes3
This commit is contained in:
commit
5e574dca77
7 changed files with 52 additions and 39 deletions
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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 = ({
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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) },
|
||||
}
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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],
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue