refactor: remove restore tab popup and its functionalities (#3867)
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
import {
|
||||
runMutation,
|
||||
runGQLQuery,
|
||||
} from "@hoppscotch/common/helpers/backend/GQLClient"
|
||||
import {
|
||||
GetCurrentRestSessionDocument,
|
||||
GetCurrentRestSessionQuery,
|
||||
GetCurrentRestSessionQueryVariables,
|
||||
SessionType,
|
||||
UpdateUserSessionDocument,
|
||||
UpdateUserSessionMutation,
|
||||
UpdateUserSessionMutationVariables,
|
||||
} from "../../api/generated/graphql"
|
||||
|
||||
export const updateUserSession = (
|
||||
currentSession: string,
|
||||
sessionType: SessionType
|
||||
) =>
|
||||
runMutation<
|
||||
UpdateUserSessionMutation,
|
||||
UpdateUserSessionMutationVariables,
|
||||
""
|
||||
>(UpdateUserSessionDocument, {
|
||||
sessionType,
|
||||
currentSession,
|
||||
})()
|
||||
|
||||
export const getCurrentRestSession = () =>
|
||||
runGQLQuery<
|
||||
GetCurrentRestSessionQuery,
|
||||
GetCurrentRestSessionQueryVariables,
|
||||
""
|
||||
>({
|
||||
query: GetCurrentRestSessionDocument,
|
||||
variables: {},
|
||||
})
|
||||
@@ -1,38 +0,0 @@
|
||||
import { PersistableTabState } from "@hoppscotch/common/services/tab"
|
||||
import { HoppRESTDocument } from "@hoppscotch/common/helpers/rest/document"
|
||||
import { HoppUser } from "@hoppscotch/common/platform/auth"
|
||||
import { TabStatePlatformDef } from "@hoppscotch/common/platform/tab"
|
||||
import { def as platformAuth } from "@platform/auth/auth.platform"
|
||||
import { getCurrentRestSession, updateUserSession } from "./tabState.api"
|
||||
import { SessionType } from "../../api/generated/graphql"
|
||||
import * as E from "fp-ts/Either"
|
||||
|
||||
async function writeCurrentTabState(
|
||||
_: HoppUser,
|
||||
persistableTabState: PersistableTabState<HoppRESTDocument>
|
||||
) {
|
||||
await updateUserSession(JSON.stringify(persistableTabState), SessionType.Rest)
|
||||
}
|
||||
|
||||
async function loadTabStateFromSync(): Promise<PersistableTabState<HoppRESTDocument> | null> {
|
||||
const currentUser = platformAuth.getCurrentUser()
|
||||
|
||||
if (!currentUser)
|
||||
throw new Error("Cannot load request from sync without login")
|
||||
|
||||
const res = await getCurrentRestSession()
|
||||
|
||||
if (E.isRight(res)) {
|
||||
const currentRESTSession = res.right.me.currentRESTSession
|
||||
|
||||
return currentRESTSession ? JSON.parse(currentRESTSession) : null
|
||||
} else {
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
export const def: TabStatePlatformDef = {
|
||||
loadTabStateFromSync,
|
||||
writeCurrentTabState,
|
||||
}
|
||||
Reference in New Issue
Block a user