fix not defaulting to hardcoded defaults
This commit is contained in:
parent
6a8abf1b32
commit
18b10ea042
6 changed files with 26 additions and 31 deletions
|
|
@ -21,14 +21,7 @@ export default {
|
|||
Popover,
|
||||
LocalSettingIndicator,
|
||||
},
|
||||
props: [
|
||||
'name',
|
||||
'label',
|
||||
'modelValue',
|
||||
'fallback',
|
||||
'options',
|
||||
'no-inherit',
|
||||
],
|
||||
props: ['name', 'label', 'modelValue', 'fallback', 'options', 'no-inherit'],
|
||||
mounted() {
|
||||
useInterfaceStore().queryLocalFonts()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -191,9 +191,12 @@ export const makeUndefined = (c) =>
|
|||
export const defaultState = {
|
||||
// Set these to undefined so it does not interfere with default settings check
|
||||
...makeUndefined(instanceDefaultConfig),
|
||||
...makeUndefined(defaultConfigLocal),
|
||||
// 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
|
||||
// # Special processing
|
||||
// ## Theme stuff
|
||||
theme: undefined, // Very old theme store, stores preset name, still in use
|
||||
|
||||
// V1
|
||||
|
|
@ -220,15 +223,4 @@ export const defaultState = {
|
|||
monospace: undefined,
|
||||
},
|
||||
},
|
||||
|
||||
// Special handling: These fields are not of a primitive type, and
|
||||
// might cause problems with current code because it specifically checks
|
||||
// them in state.config (not getters.mergedConfig).
|
||||
|
||||
// Specifically, muteWords is now deprecated in favour of a server-side configuration.
|
||||
muteWords: [],
|
||||
highlight: {},
|
||||
|
||||
// If there are any configurations that does not make sense to
|
||||
// have instance-wide default, put it here and explain why.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -182,6 +182,4 @@ export const defaultConfigLocal = {
|
|||
mentionLinkDisplay: 'short',
|
||||
imageCompression: true,
|
||||
alwaysUseJpeg: false,
|
||||
imageCompression: true,
|
||||
alwaysUseJpeg: false,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export const useLocalConfigStore = defineStore('local_config', {
|
|||
unset({ path, value }) {
|
||||
set(this.prefsStorage, path, undefined)
|
||||
},
|
||||
clearSyncConfig() {
|
||||
clearLocalConfig() {
|
||||
const blankState = { ...cloneDeep(defaultState) }
|
||||
Object.keys(this).forEach((k) => {
|
||||
this.prefsStorage[k] = blankState[k]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,11 @@ import { useInstanceStore } from 'src/stores/instance.js'
|
|||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
import { defaultState as configDefaultState, makeUndefined, defaultConfigLocal } from 'src/modules/default_config_state.js'
|
||||
import {
|
||||
defaultState as configDefaultState,
|
||||
defaultConfigLocal,
|
||||
instanceDefaultConfig,
|
||||
} from 'src/modules/default_config_state.js'
|
||||
import { defaultConfigSync } from 'src/modules/old_default_config_state.js'
|
||||
|
||||
export const VERSION = 2
|
||||
|
|
@ -50,7 +54,8 @@ export const defaultState = {
|
|||
dontShowUpdateNotifs: false,
|
||||
collapseNav: false,
|
||||
muteFilters: {},
|
||||
...makeUndefined(configDefaultState),
|
||||
|
||||
...configDefaultState,
|
||||
},
|
||||
collections: {
|
||||
pinnedStatusActions: ['reply', 'retweet', 'favorite', 'emoji'],
|
||||
|
|
@ -616,7 +621,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
let dirty = false
|
||||
|
||||
console.debug('Migrating from old config')
|
||||
const vuexState = await storage.getItem('vuex-lz') ?? {}
|
||||
const vuexState = (await storage.getItem('vuex-lz')) ?? {}
|
||||
vuexState.config = vuexState.config ?? {}
|
||||
|
||||
const migratedEntries = new Set(vuexState.config._syncMigration ?? [])
|
||||
|
|
@ -631,7 +636,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
const different = !isEqual(oldValue, defaultValue)
|
||||
|
||||
if (present && !migrated && different) {
|
||||
console.debug(`Migrating config ${key}: ${oldValue}`,)
|
||||
console.debug(`Migrating config ${key}: ${oldValue}`)
|
||||
this.setPreference({ path: `simple.${key}`, oldValue })
|
||||
migratedEntries.add(key)
|
||||
needUpload = true
|
||||
|
|
@ -721,8 +726,15 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
Object.entries(state.prefsStorage.simple).map(([k, value]) => [
|
||||
k,
|
||||
LOCAL_ONLY_KEYS.has(k)
|
||||
? tempPrefs[k] ?? localPrefs[k] ?? instancePrefs[k]
|
||||
: tempPrefs[k] ?? localPrefs[k] ?? value ?? instancePrefs[k],
|
||||
? (tempPrefs[k] ??
|
||||
localPrefs[k] ??
|
||||
instancePrefs[k] ??
|
||||
defaultConfigLocal[k])
|
||||
: (tempPrefs[k] ??
|
||||
localPrefs[k] ??
|
||||
value ??
|
||||
instancePrefs[k] ??
|
||||
instanceDefaultConfig[k]),
|
||||
]),
|
||||
)
|
||||
return result
|
||||
|
|
|
|||
|
|
@ -278,7 +278,7 @@ export const useUserHighlightStore = defineStore('user_highlight', {
|
|||
const userNew = userData.created_at > NEW_USER_DATE
|
||||
let dirty = false
|
||||
|
||||
const vuexState = await storage.getItem('vuex-lz') ?? {}
|
||||
const vuexState = (await storage.getItem('vuex-lz')) ?? {}
|
||||
vuexState.config = vuexState.config ?? {}
|
||||
const highlight = vuexState.config.highlight ?? {}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue