fix import
This commit is contained in:
parent
1b59cb3bdf
commit
c1d7d2fa63
2 changed files with 42 additions and 39 deletions
|
|
@ -143,49 +143,52 @@ const SettingsModal = {
|
|||
})
|
||||
}
|
||||
},
|
||||
onImport(data) {
|
||||
if (data) {
|
||||
Object.entries(data).forEach(([path, value]) => {
|
||||
if (LOCAL_ONLY_KEYS.has(path)) {
|
||||
useLocalConfigStore().set({ path, value })
|
||||
onImport(input) {
|
||||
if (!input) return
|
||||
const { _pleroma_settings_version, ...data } = input
|
||||
|
||||
Object.entries(data).forEach(([path, value]) => {
|
||||
const definition = ROOT_CONFIG_DEFINITIONS[path]
|
||||
|
||||
const finalValue = validateSetting({
|
||||
path,
|
||||
value,
|
||||
definition,
|
||||
throwError: false,
|
||||
defaultState: ROOT_CONFIG,
|
||||
})
|
||||
|
||||
if (finalValue === undefined) return
|
||||
|
||||
if (LOCAL_ONLY_KEYS.has(path)) {
|
||||
useLocalConfigStore().set({ path, value: finalValue })
|
||||
} else {
|
||||
if (path.startsWith('muteFilters')) {
|
||||
Object.keys(
|
||||
useMergedConfigStore().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 {
|
||||
if (path.startsWith('muteFilters')) {
|
||||
Object.keys(
|
||||
useMergedConfigStore().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 {
|
||||
const definition = ROOT_CONFIG_DEFINITIONS[path]
|
||||
|
||||
const finalValue = validateSetting({
|
||||
if (finalValue !== undefined) {
|
||||
useSyncConfigStore().setPreference({
|
||||
path: `simple.${path}`,
|
||||
value,
|
||||
definition,
|
||||
throwError: false,
|
||||
defaultState: ROOT_CONFIG,
|
||||
value: finalValue,
|
||||
})
|
||||
|
||||
if (finalValue !== undefined) {
|
||||
useSyncConfigStore().setPreference({
|
||||
path: `simple.${path}`,
|
||||
value,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
}
|
||||
}
|
||||
})
|
||||
useSyncConfigStore().pushSyncConfig()
|
||||
},
|
||||
restore() {
|
||||
this.dataImporter.importData()
|
||||
|
|
|
|||
|
|
@ -738,7 +738,7 @@ export const validateSetting = ({
|
|||
}) => {
|
||||
if (value === undefined) return // only null is allowed as missing value
|
||||
if (get(defaultState, path) === undefined) {
|
||||
const string = `Unknown instance option ${path}, value: ${value}`
|
||||
const string = `Unknown option ${path}, value: ${value}`
|
||||
|
||||
if (throwError) {
|
||||
throw new Error(string)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue