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,
|
Popover,
|
||||||
LocalSettingIndicator,
|
LocalSettingIndicator,
|
||||||
},
|
},
|
||||||
props: [
|
props: ['name', 'label', 'modelValue', 'fallback', 'options', 'no-inherit'],
|
||||||
'name',
|
|
||||||
'label',
|
|
||||||
'modelValue',
|
|
||||||
'fallback',
|
|
||||||
'options',
|
|
||||||
'no-inherit',
|
|
||||||
],
|
|
||||||
mounted() {
|
mounted() {
|
||||||
useInterfaceStore().queryLocalFonts()
|
useInterfaceStore().queryLocalFonts()
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -191,9 +191,12 @@ export const makeUndefined = (c) =>
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
// 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(instanceDefaultConfig),
|
...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
|
// # Special processing
|
||||||
// Theme stuff
|
// ## Theme stuff
|
||||||
theme: undefined, // Very old theme store, stores preset name, still in use
|
theme: undefined, // Very old theme store, stores preset name, still in use
|
||||||
|
|
||||||
// V1
|
// V1
|
||||||
|
|
@ -220,15 +223,4 @@ export const defaultState = {
|
||||||
monospace: undefined,
|
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',
|
mentionLinkDisplay: 'short',
|
||||||
imageCompression: true,
|
imageCompression: true,
|
||||||
alwaysUseJpeg: false,
|
alwaysUseJpeg: false,
|
||||||
imageCompression: true,
|
|
||||||
alwaysUseJpeg: false,
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ export const useLocalConfigStore = defineStore('local_config', {
|
||||||
unset({ path, value }) {
|
unset({ path, value }) {
|
||||||
set(this.prefsStorage, path, undefined)
|
set(this.prefsStorage, path, undefined)
|
||||||
},
|
},
|
||||||
clearSyncConfig() {
|
clearLocalConfig() {
|
||||||
const blankState = { ...cloneDeep(defaultState) }
|
const blankState = { ...cloneDeep(defaultState) }
|
||||||
Object.keys(this).forEach((k) => {
|
Object.keys(this).forEach((k) => {
|
||||||
this.prefsStorage[k] = blankState[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 { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
|
|
||||||
import { storage } from 'src/lib/storage.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'
|
import { defaultConfigSync } from 'src/modules/old_default_config_state.js'
|
||||||
|
|
||||||
export const VERSION = 2
|
export const VERSION = 2
|
||||||
|
|
@ -50,7 +54,8 @@ export const defaultState = {
|
||||||
dontShowUpdateNotifs: false,
|
dontShowUpdateNotifs: false,
|
||||||
collapseNav: false,
|
collapseNav: false,
|
||||||
muteFilters: {},
|
muteFilters: {},
|
||||||
...makeUndefined(configDefaultState),
|
|
||||||
|
...configDefaultState,
|
||||||
},
|
},
|
||||||
collections: {
|
collections: {
|
||||||
pinnedStatusActions: ['reply', 'retweet', 'favorite', 'emoji'],
|
pinnedStatusActions: ['reply', 'retweet', 'favorite', 'emoji'],
|
||||||
|
|
@ -616,7 +621,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
let dirty = false
|
let dirty = false
|
||||||
|
|
||||||
console.debug('Migrating from old config')
|
console.debug('Migrating from old config')
|
||||||
const vuexState = await storage.getItem('vuex-lz') ?? {}
|
const vuexState = (await storage.getItem('vuex-lz')) ?? {}
|
||||||
vuexState.config = vuexState.config ?? {}
|
vuexState.config = vuexState.config ?? {}
|
||||||
|
|
||||||
const migratedEntries = new Set(vuexState.config._syncMigration ?? [])
|
const migratedEntries = new Set(vuexState.config._syncMigration ?? [])
|
||||||
|
|
@ -631,7 +636,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
const different = !isEqual(oldValue, defaultValue)
|
const different = !isEqual(oldValue, defaultValue)
|
||||||
|
|
||||||
if (present && !migrated && different) {
|
if (present && !migrated && different) {
|
||||||
console.debug(`Migrating config ${key}: ${oldValue}`,)
|
console.debug(`Migrating config ${key}: ${oldValue}`)
|
||||||
this.setPreference({ path: `simple.${key}`, oldValue })
|
this.setPreference({ path: `simple.${key}`, oldValue })
|
||||||
migratedEntries.add(key)
|
migratedEntries.add(key)
|
||||||
needUpload = true
|
needUpload = true
|
||||||
|
|
@ -721,8 +726,15 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
||||||
Object.entries(state.prefsStorage.simple).map(([k, value]) => [
|
Object.entries(state.prefsStorage.simple).map(([k, value]) => [
|
||||||
k,
|
k,
|
||||||
LOCAL_ONLY_KEYS.has(k)
|
LOCAL_ONLY_KEYS.has(k)
|
||||||
? tempPrefs[k] ?? localPrefs[k] ?? instancePrefs[k]
|
? (tempPrefs[k] ??
|
||||||
: tempPrefs[k] ?? localPrefs[k] ?? value ?? instancePrefs[k],
|
localPrefs[k] ??
|
||||||
|
instancePrefs[k] ??
|
||||||
|
defaultConfigLocal[k])
|
||||||
|
: (tempPrefs[k] ??
|
||||||
|
localPrefs[k] ??
|
||||||
|
value ??
|
||||||
|
instancePrefs[k] ??
|
||||||
|
instanceDefaultConfig[k]),
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
|
|
@ -278,7 +278,7 @@ export const useUserHighlightStore = defineStore('user_highlight', {
|
||||||
const userNew = userData.created_at > NEW_USER_DATE
|
const userNew = userData.created_at > NEW_USER_DATE
|
||||||
let dirty = false
|
let dirty = false
|
||||||
|
|
||||||
const vuexState = await storage.getItem('vuex-lz') ?? {}
|
const vuexState = (await storage.getItem('vuex-lz')) ?? {}
|
||||||
vuexState.config = vuexState.config ?? {}
|
vuexState.config = vuexState.config ?? {}
|
||||||
const highlight = vuexState.config.highlight ?? {}
|
const highlight = vuexState.config.highlight ?? {}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue