From 6aa6fb5c0abae50153ec3cacf5e822231bebe2b0 Mon Sep 17 00:00:00 2001 From: s-r-x Date: Mon, 9 Aug 2021 09:07:17 +0500 Subject: [PATCH 1/2] fix: broken settings persistence --- newstore/localpersistence.ts | 43 +++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/newstore/localpersistence.ts b/newstore/localpersistence.ts index be030f1d2..eab7527f5 100644 --- a/newstore/localpersistence.ts +++ b/newstore/localpersistence.ts @@ -2,7 +2,7 @@ import clone from "lodash/clone" import assign from "lodash/assign" -import eq from "lodash/eq" +import isEmpty from "lodash/isEmpty" import { settingsStore, bulkApplySettings, @@ -27,39 +27,46 @@ import { replaceEnvironments, environments$ } from "./environments" function checkAndMigrateOldSettings() { const vuexData = JSON.parse(window.localStorage.getItem("vuex") || "{}") - if (eq(vuexData, {})) return + if (isEmpty(vuexData)) return - if (vuexData.postwoman && vuexData.postwoman.settings) { - const settingsData = clone(defaultSettings) - assign(settingsData, vuexData.postwoman.settings) + const { postwoman } = vuexData + + if (!isEmpty(postwoman?.settings)) { + const settingsData = assign(clone(defaultSettings), postwoman.settings) window.localStorage.setItem("settings", JSON.stringify(settingsData)) - delete vuexData.postwoman.settings + delete postwoman.settings window.localStorage.setItem("vuex", JSON.stringify(vuexData)) } - if (vuexData.postwoman && vuexData.postwoman.collections) { - const restColls = vuexData.postwoman.collections - window.localStorage.setItem("collections", JSON.stringify(restColls)) + if (postwoman?.collections) { + window.localStorage.setItem( + "collections", + JSON.stringify(postwoman.collections) + ) - delete vuexData.postwoman.collections + delete postwoman.collections window.localStorage.setItem("vuex", JSON.stringify(vuexData)) } - if (vuexData.postwoman && vuexData.postwoman.collectionsGraphql) { - const gqlColls = vuexData.postwoman.collectionsGraphql - window.localStorage.setItem("collectionsGraphql", JSON.stringify(gqlColls)) + if (postwoman?.collectionsGraphql) { + window.localStorage.setItem( + "collectionsGraphql", + JSON.stringify(postwoman.collectionsGraphql) + ) - delete vuexData.postwoman.collectionsGraphql + delete postwoman.collectionsGraphql window.localStorage.setItem("vuex", JSON.stringify(vuexData)) } - if (vuexData.postwoman && vuexData.postwoman.environments) { - const envs = vuexData.postwoman.environments - window.localStorage.setItem("environments", JSON.stringify(envs)) + if (postwoman?.environments) { + window.localStorage.setItem( + "environments", + JSON.stringify(postwoman.environments) + ) - delete vuexData.postwoman.environments + delete postwoman.environments window.localStorage.setItem("vuex", JSON.stringify(vuexData)) } From 058c1090e3c94f6464fc34a12aebb3442e4360b0 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Mon, 9 Aug 2021 12:56:20 +0530 Subject: [PATCH 2/2] fix: remove settings entries from postwoman.js --- store/postwoman.js | 69 ---------------------------------------------- 1 file changed, 69 deletions(-) diff --git a/store/postwoman.js b/store/postwoman.js index 14fd4f497..44586096c 100644 --- a/store/postwoman.js +++ b/store/postwoman.js @@ -1,52 +1,6 @@ import Vue from "vue" -export const SETTINGS_KEYS = [ - /** - * Whether or not to enable scrolling to a specified element, when certain - * actions are triggered. - */ - "SCROLL_INTO_ENABLED", - - /** - * Whether or not requests should be proxied. - */ - "PROXY_ENABLED", - - /** - * The URL of the proxy to connect to for requests. - */ - "PROXY_URL", - - /** - * The security key of the proxy. - */ - "PROXY_KEY", - - /** - * An array of properties to exclude from the URL. - * e.g. 'auth' - */ - "URL_EXCLUDES", - - /** - * A boolean value indicating whether to use the browser extensions - * to run the requests - */ - "EXTENSIONS_ENABLED", - - /** - * A boolean value indicating whether Telemetry is enabled. - */ - "TELEMETRY_ENABLED", - - /** - * A boolean value indicating whether to use the URL bar experiments - */ - "EXPERIMENTAL_URL_BAR_ENABLED", -] - export const state = () => ({ - settings: {}, editingEnvironment: {}, selectedRequest: {}, selectedGraphqlRequest: {}, @@ -54,29 +8,6 @@ export const state = () => ({ }) export const mutations = { - applySetting({ settings }, setting) { - if ( - setting === null || - !(setting instanceof Array) || - setting.length !== 2 - ) { - throw new Error( - "You must provide a setting (array in the form [key, value])" - ) - } - - const [key, value] = setting - // Do not just remove this check. - // Add your settings key to the SETTINGS_KEYS array at the - // top of the file. - // This is to ensure that application settings remain documented. - if (!SETTINGS_KEYS.includes(key)) { - throw new Error(`The settings structure does not include the key ${key}`) - } - - settings[key] = value - }, - removeVariables({ editingEnvironment }, value) { editingEnvironment.variables = value },