Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
refactor: remove restore tab popup and its functionalities (#3867)
Nivedin4798d7bbbd89
diff --git a/packages/hoppscotch-common/src/pages/index.vue b/packages/hoppscotch-common/src/pages/index.vueindex ecd169105..aa1fb8478 100644--- a/packages/hoppscotch-common/src/pages/index.vue+++ b/packages/hoppscotch-common/src/pages/index.vue@@ -95,31 +95,15 @@</template><script lang="ts" setup>-import { ref, onMounted, onBeforeUnmount } from "vue"+import { ref, onMounted } from "vue"import { safelyExtractRESTRequest } from "@hoppscotch/data"import { translateExtURLParams } from "~/helpers/RESTExtURLParams"import { useRoute } from "vue-router"import { useI18n } from "@composables/i18n"import { getDefaultRESTRequest } from "~/helpers/rest/default"import { defineActionHandler, invokeAction } from "~/helpers/actions"-import { onLoggedIn } from "~/composables/auth"import { platform } from "~/platform"-import {- audit,- BehaviorSubject,- combineLatest,- EMPTY,- from,- map,- Subscription,-} from "rxjs"-import { useToast } from "~/composables/toast"-import { watchDebounced } from "@vueuse/core"import { useReadonlyStream } from "~/composables/stream"-import {- changeCurrentSyncStatus,- currentSyncingStatus$,-} from "~/newstore/syncing"import { useService } from "dioc/vue"import { InspectionService } from "~/services/inspection"import { HeaderInspectorService } from "~/services/inspection/inspectors/header.inspector"@@ -127,7 +111,7 @@ import { EnvironmentInspectorService } from "~/services/inspection/inspectors/enimport { ResponseInspectorService } from "~/services/inspection/inspectors/response.inspector"import { cloneDeep } from "lodash-es"import { RESTTabService } from "~/services/tab/rest"-import { HoppTab, PersistableTabState } from "~/services/tab"+import { HoppTab } from "~/services/tab"import { HoppRESTDocument } from "~/helpers/rest/document"const savingRequest = ref(false)@@ -140,7 +124,6 @@ const exceptedTabID = ref<string | null>(null)const renameTabID = ref<string | null>(null)const t = useI18n()-const toast = useToast()const tabs = useService(RESTTabService)@@ -171,12 +154,6 @@ const contextMenu = ref<PopupDetails>({const activeTabs = tabs.getActiveTabs()-const confirmSync = useReadonlyStream(currentSyncingStatus$, {- isInitialSync: false,- shouldSync: true,-})-const tabStateForSync = ref<PersistableTabState<HoppRESTDocument> | null>(null)-function bindRequestToURLParams() {const route = useRoute()// Get URL parameters and set that as the request@@ -327,111 +304,6 @@ const shareTabRequest = (tabID: string) => {}}-const syncTabState = () => {- if (tabStateForSync.value)- tabs.loadTabsFromPersistedState(tabStateForSync.value)-}--/**- * Performs sync of the REST Tab session with Firestore.- *- * @returns A subscription to the sync observable stream.- * Unsubscribe to stop syncing.- */-function startTabStateSync(): Subscription {- const currentUser$ = platform.auth.getCurrentUserStream()- const tabState$ =- new BehaviorSubject<PersistableTabState<HoppRESTDocument> | null>(null)-- watchDebounced(- tabs.persistableTabState,- (state) => {- tabState$.next(state)- },- { debounce: 500, deep: true }- )-- const sub = combineLatest([currentUser$, tabState$])- .pipe(- map(([user, tabState]) =>- user && tabState- ? from(platform.sync.tabState.writeCurrentTabState(user, tabState))- : EMPTY- ),- audit((x) => x)- )- .subscribe(() => {- // NOTE: This subscription should be kept- })-- return sub-}--const showSyncToast = () => {- toast.show(t("confirm.sync"), {- duration: 0,- action: [- {- text: `${t("action.yes")}`,- onClick: (_, toastObject) => {- syncTabState()- changeCurrentSyncStatus({- isInitialSync: true,- shouldSync: true,- })- toastObject.goAway(0)- },- },- {- text: `${t("action.no")}`,- onClick: (_, toastObject) => {- changeCurrentSyncStatus({- isInitialSync: true,- shouldSync: false,- })- toastObject.goAway(0)- },- },- ],- })-}--function setupTabStateSync() {- const route = useRoute()-- // Subscription to request sync- let sub: Subscription | null = null-- // Load request on login resolve and start sync- onLoggedIn(async () => {- if (- Object.keys(route.query).length === 0 &&- !(route.query.code || route.query.error)- ) {- const tabStateFromSync =- await platform.sync.tabState.loadTabStateFromSync()-- if (tabStateFromSync && !confirmSync.value.isInitialSync) {- tabStateForSync.value = tabStateFromSync- showSyncToast()- // Have to set isInitialSync to true here because the toast is shown- // and the user does not click on any of the actions- changeCurrentSyncStatus({- isInitialSync: true,- shouldSync: false,- })- }- }-- sub = startTabStateSync()- })-- // Stop subscription to stop syncing- onBeforeUnmount(() => {- sub?.unsubscribe()- })-}-defineActionHandler("contextmenu.open", ({ position, text }) => {if (text) {contextMenu.value = {@@ -448,7 +320,6 @@ defineActionHandler("contextmenu.open", ({ position, text }) => {}})-setupTabStateSync()bindRequestToURLParams()defineActionHandler("rest.request.open", ({ doc }) => {diff --git a/packages/hoppscotch-common/src/platform/index.ts b/packages/hoppscotch-common/src/platform/index.tsindex 545987df4..fc4882bcc 100644--- a/packages/hoppscotch-common/src/platform/index.ts+++ b/packages/hoppscotch-common/src/platform/index.ts@@ -4,7 +4,6 @@ import { EnvironmentsPlatformDef } from "./environments"import { CollectionsPlatformDef } from "./collections"import { SettingsPlatformDef } from "./settings"import { HistoryPlatformDef } from "./history"-import { TabStatePlatformDef } from "./tab"import { AnalyticsPlatformDef } from "./analytics"import { InterceptorsPlatformDef } from "./interceptors"import { HoppModule } from "~/modules"@@ -25,7 +24,6 @@ export type PlatformDef = {collections: CollectionsPlatformDefsettings: SettingsPlatformDefhistory: HistoryPlatformDef- tabState: TabStatePlatformDef}interceptors: InterceptorsPlatformDefadditionalInspectors?: InspectorsPlatformDefdiff --git a/packages/hoppscotch-common/src/platform/tab.ts b/packages/hoppscotch-common/src/platform/tab.tsdeleted file mode 100644index 72c536b8c..000000000--- a/packages/hoppscotch-common/src/platform/tab.ts+++ /dev/null@@ -1,11 +0,0 @@-import { PersistableTabState } from "~/services/tab"-import { HoppUser } from "./auth"-import { HoppRESTDocument } from "~/helpers/rest/document"--export type TabStatePlatformDef = {- loadTabStateFromSync: () => Promise<PersistableTabState<HoppRESTDocument> | null>- writeCurrentTabState: (- user: HoppUser,- persistableTabState: PersistableTabState<HoppRESTDocument>- ) => Promise<void>-}diff --git a/packages/hoppscotch-selfhost-desktop/src/api/mutations/UpdateUserSession.graphql b/packages/hoppscotch-selfhost-desktop/src/api/mutations/UpdateUserSession.graphqldeleted file mode 100644index 5ce87e5b6..000000000--- a/packages/hoppscotch-selfhost-desktop/src/api/mutations/UpdateUserSession.graphql+++ /dev/null@@ -1,11 +0,0 @@-mutation UpdateUserSession(- $currentSession: String!- $sessionType: SessionType!-) {- updateUserSessions(- currentSession: $currentSession- sessionType: $sessionType- ) {- currentRESTSession- }-}diff --git a/packages/hoppscotch-selfhost-desktop/src/api/queries/GetCurrentRESTSession.graphql b/packages/hoppscotch-selfhost-desktop/src/api/queries/GetCurrentRESTSession.graphqldeleted file mode 100644index fee09e491..000000000--- a/packages/hoppscotch-selfhost-desktop/src/api/queries/GetCurrentRESTSession.graphql+++ /dev/null@@ -1,5 +0,0 @@-query GetCurrentRESTSession {- me {- currentRESTSession- }-}diff --git a/packages/hoppscotch-selfhost-desktop/src/main.ts b/packages/hoppscotch-selfhost-desktop/src/main.tsindex 53b98548b..5584d1ebe 100644--- a/packages/hoppscotch-selfhost-desktop/src/main.ts+++ b/packages/hoppscotch-selfhost-desktop/src/main.ts@@ -4,7 +4,6 @@ import { def as environmentsDef } from "./platform/environments/environments.plaimport { def as collectionsDef } from "./platform/collections/collections.platform"import { def as settingsDef } from "./platform/settings/settings.platform"import { def as historyDef } from "./platform/history/history.platform"-import { def as tabStateDef } from "./platform/tabState/tabState.platform"import { proxyInterceptor } from "@hoppscotch/common/platform/std/interceptors/proxy"import { ExtensionInspectorService } from "@hoppscotch/common/platform/std/inspections/extension.inspector"import { NativeInterceptorService } from "./platform/interceptors/native"@@ -46,7 +45,6 @@ const headerPaddingTop = ref("0px")collections: collectionsDef,settings: settingsDef,history: historyDef,- tabState: tabStateDef,},interceptors: {default: "native",@@ -97,17 +95,18 @@ const headerPaddingTop = ref("0px")}})()-function isTextInput(target: EventTarget | null) {if (target instanceof HTMLInputElement) {- return target.type === 'text'- || target.type === 'email'- || target.type === 'password'- || target.type === 'number'- || target.type === 'search'- || target.type === 'tel'- || target.type === 'url'- || target.type === 'textarea'+ return (+ target.type === "text" ||+ target.type === "email" ||+ target.type === "password" ||+ target.type === "number" ||+ target.type === "search" ||+ target.type === "tel" ||+ target.type === "url" ||+ target.type === "textarea"+ )} else if (target instanceof HTMLTextAreaElement) {return true} else if (target instanceof HTMLElement && target.isContentEditable) {@@ -117,8 +116,12 @@ function isTextInput(target: EventTarget | null) {return false}-window.addEventListener('keydown',function(e){- if (e.key === "Backspace" && !isTextInput(e.target)) {- e.preventDefault()- }-},true);+window.addEventListener(+ "keydown",+ function (e) {+ if (e.key === "Backspace" && !isTextInput(e.target)) {+ e.preventDefault()+ }+ },+ true+)diff --git a/packages/hoppscotch-selfhost-desktop/src/platform/tabState/tabState.api.ts b/packages/hoppscotch-selfhost-desktop/src/platform/tabState/tabState.api.tsdeleted file mode 100644index 89d87a537..000000000--- a/packages/hoppscotch-selfhost-desktop/src/platform/tabState/tabState.api.ts+++ /dev/null@@ -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: {},- })diff --git a/packages/hoppscotch-selfhost-desktop/src/platform/tabState/tabState.platform.ts b/packages/hoppscotch-selfhost-desktop/src/platform/tabState/tabState.platform.tsdeleted file mode 100644index 30420da0d..000000000--- a/packages/hoppscotch-selfhost-desktop/src/platform/tabState/tabState.platform.ts+++ /dev/null@@ -1,37 +0,0 @@-import { PersistableRESTTabState } from "@hoppscotch/common/helpers/rest/tab"-import { HoppUser } from "@hoppscotch/common/platform/auth"-import { TabStatePlatformDef } from "@hoppscotch/common/platform/tab"-import { def as platformAuth } from "@platform/auth"-import { getCurrentRestSession, updateUserSession } from "./tabState.api"-import { SessionType } from "../../api/generated/graphql"-import * as E from "fp-ts/Either"--async function writeCurrentTabState(- _: HoppUser,- persistableTabState: PersistableRESTTabState-) {- await updateUserSession(JSON.stringify(persistableTabState), SessionType.Rest)-}--async function loadTabStateFromSync(): Promise<PersistableRESTTabState | 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,-}diff --git a/packages/hoppscotch-selfhost-web/src/api/mutations/UpdateUserSession.graphql b/packages/hoppscotch-selfhost-web/src/api/mutations/UpdateUserSession.graphqldeleted file mode 100644index 5ce87e5b6..000000000--- a/packages/hoppscotch-selfhost-web/src/api/mutations/UpdateUserSession.graphql+++ /dev/null@@ -1,11 +0,0 @@-mutation UpdateUserSession(- $currentSession: String!- $sessionType: SessionType!-) {- updateUserSessions(- currentSession: $currentSession- sessionType: $sessionType- ) {- currentRESTSession- }-}diff --git a/packages/hoppscotch-selfhost-web/src/api/queries/GetCurrentRESTSession.graphql b/packages/hoppscotch-selfhost-web/src/api/queries/GetCurrentRESTSession.graphqldeleted file mode 100644index fee09e491..000000000--- a/packages/hoppscotch-selfhost-web/src/api/queries/GetCurrentRESTSession.graphql+++ /dev/null@@ -1,5 +0,0 @@-query GetCurrentRESTSession {- me {- currentRESTSession- }-}diff --git a/packages/hoppscotch-selfhost-web/src/main.ts b/packages/hoppscotch-selfhost-web/src/main.tsindex 46be730c5..c54447ccf 100644--- a/packages/hoppscotch-selfhost-web/src/main.ts+++ b/packages/hoppscotch-selfhost-web/src/main.ts@@ -4,7 +4,6 @@ import { def as environmentsDef } from "./platform/environments/environments.plaimport { def as collectionsDef } from "./platform/collections/collections.platform"import { def as settingsDef } from "./platform/settings/settings.platform"import { def as historyDef } from "./platform/history/history.platform"-import { def as tabStateDef } from "./platform/tabState/tabState.platform"import { browserInterceptor } from "@hoppscotch/common/platform/std/interceptors/browser"import { proxyInterceptor } from "@hoppscotch/common/platform/std/interceptors/proxy"import { ExtensionInspectorService } from "@hoppscotch/common/platform/std/inspections/extension.inspector"@@ -25,7 +24,6 @@ createHoppApp("#app", {collections: collectionsDef,settings: settingsDef,history: historyDef,- tabState: tabStateDef,},interceptors: {default: "browser",diff --git a/packages/hoppscotch-selfhost-web/src/platform/tabState/tabState.api.ts b/packages/hoppscotch-selfhost-web/src/platform/tabState/tabState.api.tsdeleted file mode 100644index 89d87a537..000000000--- a/packages/hoppscotch-selfhost-web/src/platform/tabState/tabState.api.ts+++ /dev/null@@ -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: {},- })diff --git a/packages/hoppscotch-selfhost-web/src/platform/tabState/tabState.platform.ts b/packages/hoppscotch-selfhost-web/src/platform/tabState/tabState.platform.tsdeleted file mode 100644index 1ce65094a..000000000--- a/packages/hoppscotch-selfhost-web/src/platform/tabState/tabState.platform.ts+++ /dev/null@@ -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,-}