even more getter fixes
This commit is contained in:
parent
7738ce87e6
commit
ca0da60bcd
24 changed files with 93 additions and 56 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import Cookies from 'js-cookie'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import messages from 'src/i18n/messages'
|
||||
import localeService from 'src/services/locale/locale.service.js'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
const BACKEND_LANGUAGE_COOKIE_NAME = 'userLanguage'
|
||||
|
||||
|
|
@ -21,6 +22,6 @@ export const useI18nStore = defineStore('i18n', {
|
|||
BACKEND_LANGUAGE_COOKIE_NAME,
|
||||
localeService.internalToBackendLocaleMulti(value),
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -252,7 +252,10 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
this.resetThemeV3Palette()
|
||||
this.resetThemeV2()
|
||||
|
||||
useSyncConfigStore().setPreference({ path: 'simple.paletteCustomData', value })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.paletteCustomData',
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
|
||||
this.applyTheme({ recompile: true })
|
||||
|
|
@ -292,7 +295,10 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
this.resetThemeV2()
|
||||
this.resetThemeV3Palette()
|
||||
|
||||
useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.styleCustomData',
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
|
||||
this.useStylePalette = true
|
||||
|
|
@ -330,18 +336,27 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
this.resetThemeV2()
|
||||
|
||||
useSyncConfigStore().setPreference({ path: 'simple.customTheme', value })
|
||||
useSyncConfigStore().setPreference({ path: 'simple.customThemeSource', value })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.customThemeSource',
|
||||
value,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
|
||||
this.applyTheme({ recompile: true })
|
||||
},
|
||||
resetThemeV3() {
|
||||
useSyncConfigStore().setPreference({ path: 'simple.style', value: null })
|
||||
useSyncConfigStore().setPreference({ path: 'simple.styleCustomData', value: null })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.styleCustomData',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
},
|
||||
resetThemeV3Palette() {
|
||||
useSyncConfigStore().setPreference({ path: 'simple.palette', value: null })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.palette',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.paletteCustomData',
|
||||
value: null,
|
||||
|
|
@ -350,7 +365,10 @@ export const useInterfaceStore = defineStore('interface', {
|
|||
},
|
||||
resetThemeV2() {
|
||||
useSyncConfigStore().setPreference({ path: 'simple.theme', value: null })
|
||||
useSyncConfigStore().setPreference({ path: 'simple.customTheme', value: null })
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.customTheme',
|
||||
value: null,
|
||||
})
|
||||
useSyncConfigStore().setPreference({
|
||||
path: 'simple.customThemeSource',
|
||||
value: null,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
import {
|
||||
cloneDeep,
|
||||
set,
|
||||
} from 'lodash'
|
||||
import { cloneDeep, set } from 'lodash'
|
||||
import { defineStore } from 'pinia'
|
||||
import { toRaw } from 'vue'
|
||||
|
||||
|
|
@ -12,7 +9,7 @@ import { defaultState as configDefaultState } from 'src/modules/default_config_s
|
|||
export const defaultState = {
|
||||
prefsStorage: {
|
||||
...configDefaultState,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export const useLocalConfigStore = defineStore('local_config', {
|
||||
|
|
|
|||
|
|
@ -97,14 +97,18 @@ const _verifyPrefs = (state) => {
|
|||
if (typeof v === 'undefined') return
|
||||
if (typeof v === 'number' || typeof v === 'boolean') return
|
||||
if (typeof v === 'object') return
|
||||
console.warn(`Preference simple.${k} as invalid type ${typeof v}, reinitializing`)
|
||||
console.warn(
|
||||
`Preference simple.${k} as invalid type ${typeof v}, reinitializing`,
|
||||
)
|
||||
set(state.prefsStorage.simple, k, defaultState.prefsStorage.simple[k])
|
||||
})
|
||||
|
||||
// Collections
|
||||
Object.entries(defaultState.prefsStorage.collections).forEach(([k, v]) => {
|
||||
if (Array.isArray(v)) return
|
||||
console.warn(`Preference collections.${k} as invalid type ${typeof v}, reinitializing`)
|
||||
console.warn(
|
||||
`Preference collections.${k} as invalid type ${typeof v}, reinitializing`,
|
||||
)
|
||||
set(
|
||||
state.prefsStorage.collections,
|
||||
k,
|
||||
|
|
@ -306,7 +310,9 @@ export const _mergePrefs = (recent, stale) => {
|
|||
break
|
||||
case 'addToCollection':
|
||||
if (!path.startsWith('collections')) {
|
||||
return console.error('Illegal operation "addToCollection" on a non-collection')
|
||||
return console.error(
|
||||
'Illegal operation "addToCollection" on a non-collection',
|
||||
)
|
||||
}
|
||||
set(
|
||||
resultOutput,
|
||||
|
|
@ -316,7 +322,9 @@ export const _mergePrefs = (recent, stale) => {
|
|||
break
|
||||
case 'removeFromCollection': {
|
||||
if (!path.startsWith('collections')) {
|
||||
return console.error('Illegal operation "removeFromCollection" on a non-collection')
|
||||
return console.error(
|
||||
'Illegal operation "removeFromCollection" on a non-collection',
|
||||
)
|
||||
}
|
||||
const newSet = new Set(get(resultOutput, path))
|
||||
newSet.delete(args[0])
|
||||
|
|
@ -438,9 +446,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
`Tried to edit internal (starts with _) field '${path}', ignoring.`,
|
||||
)
|
||||
}
|
||||
if (
|
||||
path.startsWith('collections')
|
||||
) {
|
||||
if (path.startsWith('collections')) {
|
||||
throw new Error(
|
||||
`Invalid operation 'set' for collection field '${path}', ignoring.`,
|
||||
)
|
||||
|
|
@ -468,9 +474,7 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
`Tried to edit internal (starts with _) field '${path}', ignoring.`,
|
||||
)
|
||||
}
|
||||
if (
|
||||
path.startsWith('collections')
|
||||
) {
|
||||
if (path.startsWith('collections')) {
|
||||
throw new Error(
|
||||
`Invalid operation 'unset' for collection field '${path}', ignoring.`,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue