added config stores to global scope for easier debug
This commit is contained in:
parent
30aae4a346
commit
f77e1225b5
2 changed files with 56 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
||||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||||
import { useOAuthStore } from 'src/stores/oauth'
|
import { useOAuthStore } from 'src/stores/oauth'
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
|
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
|
|
||||||
import VBodyScrollLock from 'src/directives/body_scroll_lock'
|
import VBodyScrollLock from 'src/directives/body_scroll_lock'
|
||||||
import {
|
import {
|
||||||
|
|
@ -523,6 +524,8 @@ const afterStoreSetup = async ({ pinia, store, storageError, i18n }) => {
|
||||||
|
|
||||||
useInterfaceStore().setLayoutWidth(windowWidth())
|
useInterfaceStore().setLayoutWidth(windowWidth())
|
||||||
useInterfaceStore().setLayoutHeight(windowHeight())
|
useInterfaceStore().setLayoutHeight(windowHeight())
|
||||||
|
window.syncConfig = useSyncConfigStore()
|
||||||
|
window.localConfig = useLocalConfigStore()
|
||||||
|
|
||||||
FaviconService.initFaviconService()
|
FaviconService.initFaviconService()
|
||||||
initServiceWorker(store)
|
initServiceWorker(store)
|
||||||
|
|
|
||||||
53
src/stores/local_config.js
Normal file
53
src/stores/local_config.js
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
import {
|
||||||
|
cloneDeep,
|
||||||
|
set,
|
||||||
|
} from 'lodash'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
import { toRaw } from 'vue'
|
||||||
|
|
||||||
|
import { useInstanceStore } from 'src/stores/instance'
|
||||||
|
|
||||||
|
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
|
||||||
|
|
||||||
|
export const defaultState = {
|
||||||
|
prefsStorage: {
|
||||||
|
...configDefaultState,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useLocalConfigStore = defineStore('local_config', {
|
||||||
|
state() {
|
||||||
|
return cloneDeep(defaultState)
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
set({ path, value }) {
|
||||||
|
set(this.prefsStorage, path, value)
|
||||||
|
},
|
||||||
|
unset({ path, value }) {
|
||||||
|
set(this.prefsStorage, path, undefined)
|
||||||
|
},
|
||||||
|
clearSyncConfig() {
|
||||||
|
const blankState = { ...cloneDeep(defaultState) }
|
||||||
|
Object.keys(this).forEach((k) => {
|
||||||
|
this.prefsStorage[k] = blankState[k]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
mergedConfig: (state) => {
|
||||||
|
const instancePrefs = useInstanceStore().prefsStorage
|
||||||
|
const result = Object.fromEntries(
|
||||||
|
Object.entries(state.prefsStorage).map(([k, v]) => [
|
||||||
|
k,
|
||||||
|
v ?? instancePrefs[k],
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
return result
|
||||||
|
},
|
||||||
|
},
|
||||||
|
persist: {
|
||||||
|
afterLoad(state) {
|
||||||
|
return state
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
Loading…
Add table
Add a link
Reference in a new issue