refactor: persist request handles under tab saveContext

Only the IDs (workspace, provider & request IDs) to restore the handle are stored under `localStorage` and the handle is restored back at runtime.
This commit is contained in:
jamesgeorge007
2024-04-22 20:16:02 +05:30
parent f6067f14aa
commit 8467417e7a
6 changed files with 155 additions and 15 deletions

View File

@@ -3,7 +3,12 @@ import { computed } from "vue"
import { getDefaultRESTRequest } from "~/helpers/rest/default"
import { HoppRESTDocument, HoppRESTSaveContext } from "~/helpers/rest/document"
import { TabService } from "./tab"
<<<<<<< HEAD
import { Container } from "dioc"
=======
import { HandleRef } from "../new-workspace/handle"
import { WorkspaceRequest } from "../new-workspace/workspace"
>>>>>>> 854ffa28 (refactor: persist request handles under tab `saveContext`)
export class RESTTabService extends TabService<HoppRESTDocument> {
public static readonly ID = "REST_TAB_SERVICE"
@@ -58,7 +63,16 @@ export class RESTTabService extends TabService<HoppRESTDocument> {
ctx?.originLocation === "workspace-user-collection" &&
tab.document.saveContext?.originLocation === "workspace-user-collection"
) {
if (isEqual(ctx, tab.document.saveContext)) {
if (
isEqual(
ctx.requestHandle?.value,
// TODO: Investigate why requestHandle gets unwrapped
tab.document.saveContext.requestHandle as
| HandleRef<WorkspaceRequest>["value"]
| undefined
)
) {
return this.getTabRef(tab.id)
}
}