Fix settings data migration issues
This commit is contained in:
@@ -1,18 +1,21 @@
|
|||||||
import { settingsStore, bulkApplySettings, defaultSettings } from "./settings"
|
import { settingsStore, bulkApplySettings, defaultSettings } from "./settings"
|
||||||
import clone from "lodash/clone"
|
import clone from "lodash/clone"
|
||||||
import assign from "lodash/assign"
|
import assign from "lodash/assign"
|
||||||
|
import eq from "lodash/eq"
|
||||||
|
|
||||||
function checkAndMigrateOldSettings() {
|
function checkAndMigrateOldSettings() {
|
||||||
// Don't do migration if the new settings object exists
|
|
||||||
if (window.localStorage.getItem("settings")) return
|
|
||||||
|
|
||||||
const vuexData = JSON.parse(window.localStorage.getItem("vuex") || "{}")
|
const vuexData = JSON.parse(window.localStorage.getItem("vuex") || "{}")
|
||||||
if (vuexData === {}) return
|
if (eq(vuexData, {})) return
|
||||||
|
|
||||||
const settingsData = clone(defaultSettings)
|
|
||||||
assign(settingsData, vuexData.postwoman.settings)
|
|
||||||
|
|
||||||
window.localStorage.setItem("settings", JSON.stringify(settingsData))
|
if (vuexData.postwoman && vuexData.postwoman.settings) {
|
||||||
|
const settingsData = clone(defaultSettings)
|
||||||
|
assign(settingsData, vuexData.postwoman.settings)
|
||||||
|
|
||||||
|
window.localStorage.setItem("settings", JSON.stringify(settingsData))
|
||||||
|
|
||||||
|
delete vuexData.postwoman.settings
|
||||||
|
window.localStorage.setItem("vuex", JSON.stringify(vuexData))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupSettingsPersistence() {
|
function setupSettingsPersistence() {
|
||||||
|
|||||||
Reference in New Issue
Block a user