Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

Fix settings data migration issues

Andrew Bastinc18c2ea9d450
diff --git a/newstore/localpersistence.ts b/newstore/localpersistence.ts
index 14cbeaf29..bdfb4a4a2 100644
--- a/newstore/localpersistence.ts
+++ b/newstore/localpersistence.ts
@@ -1,18 +1,21 @@
import { settingsStore, bulkApplySettings, defaultSettings } from "./settings"
import clone from "lodash/clone"
import assign from "lodash/assign"
+import eq from "lodash/eq"
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") || "{}")
- if (vuexData === {}) return
-
- const settingsData = clone(defaultSettings)
- assign(settingsData, vuexData.postwoman.settings)
+ if (eq(vuexData, {})) return
+
+ if (vuexData.postwoman && vuexData.postwoman.settings) {
+ const settingsData = clone(defaultSettings)
+ assign(settingsData, vuexData.postwoman.settings)
- window.localStorage.setItem("settings", JSON.stringify(settingsData))
+ window.localStorage.setItem("settings", JSON.stringify(settingsData))
+
+ delete vuexData.postwoman.settings
+ window.localStorage.setItem("vuex", JSON.stringify(vuexData))
+ }
}
function setupSettingsPersistence() {