fix import/export
This commit is contained in:
parent
195e353b3a
commit
d881b92f86
5 changed files with 46 additions and 7 deletions
|
|
@ -9,6 +9,7 @@ import PanelLoading from 'src/components/panel_loading/panel_loading.vue'
|
|||
import Popover from '../popover/popover.vue'
|
||||
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { LOCAL_ONLY_KEYS, useLocalConfigStore } from 'src/stores/local_config.js'
|
||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||
|
||||
import {
|
||||
|
|
@ -137,7 +138,24 @@ const SettingsModal = {
|
|||
},
|
||||
onImport(data) {
|
||||
if (data) {
|
||||
this.$store.dispatch('loadSettings', data)
|
||||
Object.entries(data).forEach(([path, value]) => {
|
||||
if (LOCAL_ONLY_KEYS.has(path)) {
|
||||
useLocalConfigStore().set({ path, value })
|
||||
} else {
|
||||
if (path.startsWith('muteFilters')) {
|
||||
Object.keys(useSyncConfigStore().mergedConfig.muteFilters).forEach((key) => {
|
||||
useSyncConfigStore().unsetPreference({ path: `simple.${path}.${key}` })
|
||||
})
|
||||
|
||||
Object.entries(value).forEach(([key, filter]) => {
|
||||
useSyncConfigStore().setPreference({ path: `simple.${path}.${key}`, value: filter })
|
||||
})
|
||||
} else {
|
||||
useSyncConfigStore().setPreference({ path: `simple.${path}`, value })
|
||||
}
|
||||
}
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
}
|
||||
},
|
||||
restore() {
|
||||
|
|
@ -150,7 +168,7 @@ const SettingsModal = {
|
|||
this.dataThemeExporter.exportData()
|
||||
},
|
||||
generateExport(theme = false) {
|
||||
const { config } = this.$store.state
|
||||
const config = useSyncConfigStore().mergedConfigWithoutDefaults
|
||||
let sample = config
|
||||
if (!theme) {
|
||||
const ignoreList = new Set([
|
||||
|
|
@ -159,7 +177,9 @@ const SettingsModal = {
|
|||
'colors',
|
||||
])
|
||||
sample = Object.fromEntries(
|
||||
Object.entries(sample).filter(([key]) => !ignoreList.has(key)),
|
||||
Object.entries(sample).filter(
|
||||
([key, value]) => !ignoreList.has(key) && value !== undefined,
|
||||
),
|
||||
)
|
||||
}
|
||||
const clone = cloneDeep(sample)
|
||||
|
|
|
|||
|
|
@ -93,8 +93,6 @@ const FilteringTab = {
|
|||
computed: {
|
||||
...SharedComputedObject(),
|
||||
...mapState(useSyncConfigStore, {
|
||||
muteFilters: (store) =>
|
||||
Object.entries(store.prefsStorage.simple.muteFilters),
|
||||
muteFiltersObject: (store) => store.prefsStorage.simple.muteFilters,
|
||||
}),
|
||||
...mapState(useInstanceCapabilitiesStore, ['blockExpiration']),
|
||||
|
|
@ -260,6 +258,12 @@ const FilteringTab = {
|
|||
replyVisibility() {
|
||||
this.$store.dispatch('queueFlushAll')
|
||||
},
|
||||
muteFiltersObject() {
|
||||
console.log('UPDATE')
|
||||
this.muteFiltersDraftObject = cloneDeep(
|
||||
useSyncConfigStore().prefsStorage.simple.muteFilters,
|
||||
)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -381,6 +381,7 @@
|
|||
"select_all": "Select all"
|
||||
},
|
||||
"settings": {
|
||||
"invalid_settings_imported": "Error importing settings",
|
||||
"add_language": "Add fallback language",
|
||||
"remove_language": "Remove",
|
||||
"primary_language": "Primary language:",
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import { useInstanceStore } from 'src/stores/instance'
|
|||
|
||||
import { defaultState as configDefaultState } from 'src/modules/default_config_state'
|
||||
|
||||
export const LOCAL_ONLY_KEYS = new Set(Object.keys(configDefaultState))
|
||||
|
||||
export const defaultState = {
|
||||
prefsStorage: {
|
||||
...configDefaultState,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,10 @@ import { toRaw } from 'vue'
|
|||
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
||||
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||
import {
|
||||
LOCAL_ONLY_KEYS,
|
||||
useLocalConfigStore,
|
||||
} from 'src/stores/local_config.js'
|
||||
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
import {
|
||||
|
|
@ -35,7 +38,6 @@ export const COMMAND_TRIM_FLAGS = 1000
|
|||
export const COMMAND_TRIM_FLAGS_AND_RESET = 1001
|
||||
export const COMMAND_WIPE_JOURNAL = 1010
|
||||
export const COMMAND_WIPE_JOURNAL_AND_STORAGE = 1011
|
||||
const LOCAL_ONLY_KEYS = new Set(Object.keys(defaultConfigLocal))
|
||||
|
||||
export const defaultState = {
|
||||
// do we need to update data on server?
|
||||
|
|
@ -739,6 +741,16 @@ export const useSyncConfigStore = defineStore('sync_config', {
|
|||
)
|
||||
return result
|
||||
},
|
||||
mergedConfigWithoutDefaults: (state) => {
|
||||
const localPrefs = useLocalConfigStore().prefsStorage
|
||||
const result = Object.fromEntries(
|
||||
Object.entries(state.prefsStorage.simple).map(([k, value]) => [
|
||||
k,
|
||||
LOCAL_ONLY_KEYS.has(k) ? localPrefs[k] : value,
|
||||
]),
|
||||
)
|
||||
return result
|
||||
},
|
||||
},
|
||||
persist: {
|
||||
afterLoad(state) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue