feat: gql revamp (#2644)

Co-authored-by: Liyas Thomas <liyascthomas@gmail.com>
Co-authored-by: Andrew Bastin <andrewbastin.k@gmail.com>
This commit is contained in:
Anwarul Islam
2023-08-22 18:13:43 +06:00
committed by GitHub
parent 191fa376d2
commit 88212e8cfe
41 changed files with 2503 additions and 1702 deletions

View File

@@ -48,8 +48,10 @@ import {
loadTabsFromPersistedState,
persistableTabState,
} from "~/helpers/rest/tab"
import { debounceTime } from "rxjs"
import { gqlSessionStore, setGQLSession } from "./GQLSession"
import {
loadTabsFromPersistedState as loadGQLTabsFromPersistedState,
persistableTabState as persistableGQLTabState,
} from "~/helpers/graphql/tab"
function checkAndMigrateOldSettings() {
if (window.localStorage.getItem("selectedEnvIndex")) {
@@ -340,26 +342,27 @@ export function setupRESTTabsPersistence() {
)
}
// temporary persistence for GQL session
export function setupGQLPersistence() {
function setupGQLTabsPersistence() {
try {
const state = window.localStorage.getItem("gqlState")
const state = window.localStorage.getItem("gqlTabState")
if (state) {
const data = JSON.parse(state)
data["schema"] = ""
data["response"] = ""
setGQLSession(data)
loadGQLTabsFromPersistedState(data)
}
} catch (e) {
console.error(
`Failed parsing persisted GraphQL state, state:`,
window.localStorage.getItem("gqlState")
`Failed parsing persisted tab state, state:`,
window.localStorage.getItem("gqlTabState")
)
}
gqlSessionStore.subject$.pipe(debounceTime(500)).subscribe((state) => {
window.localStorage.setItem("gqlState", JSON.stringify(state))
})
watchDebounced(
persistableGQLTabState,
(state) => {
window.localStorage.setItem("gqlTabState", JSON.stringify(state))
},
{ debounce: 500, deep: true }
)
}
export function setupLocalPersistence() {
@@ -368,7 +371,9 @@ export function setupLocalPersistence() {
setupLocalStatePersistence()
setupSettingsPersistence()
setupRESTTabsPersistence()
setupGQLPersistence()
setupGQLTabsPersistence()
setupHistoryPersistence()
setupCollectionsPersistence()
setupGlobalEnvsPersistence()