Browse Source

fix: ensure tree nodes are not computed for requests

jamesgeorge007 1 year ago
parent
commit
396cdd9469

+ 3 - 2
packages/hoppscotch-common/src/helpers/adapters/WorkspaceRESTCollectionSearchTreeAdapter.ts

@@ -10,7 +10,8 @@ export class WorkspaceRESTSearchCollectionTreeAdapter
   constructor(public data: Ref<HoppCollection[]>) {}
 
   getChildren(
-    nodeID: string | null
+    nodeID: string | null,
+    nodeType?: string
   ): Ref<ChildrenResult<RESTCollectionViewItem>> {
     const result = ref<ChildrenResult<RESTCollectionViewItem>>({
       status: "loading",
@@ -34,7 +35,7 @@ export class WorkspaceRESTSearchCollectionTreeAdapter
             },
           })),
         }
-      } else {
+      } else if (nodeType === "collection") {
         const indexPath = nodeID.split("/").map((x) => parseInt(x))
 
         const item = navigateToFolderWithIndexPath(this.data.value, indexPath)

+ 6 - 1
packages/hoppscotch-common/src/helpers/adapters/WorkspaceRESTCollectionTreeAdapter.ts

@@ -18,7 +18,8 @@ export class WorkspaceRESTCollectionTreeAdapter
   ) {}
 
   public getChildren(
-    nodeID: string | null
+    nodeID: string | null,
+    nodeType?: string
   ): Ref<ChildrenResult<RESTCollectionViewItem>> {
     if (this.workspaceHandle.value.type !== "ok") {
       throw new Error("Cannot issue children with invalid workspace handle")
@@ -30,6 +31,10 @@ export class WorkspaceRESTCollectionTreeAdapter
 
     if (nodeID !== null) {
       ;(async () => {
+        if (nodeType === "request") {
+          return
+        }
+
         const collectionHandleResult =
           await this.workspaceService.getCollectionHandle(
             this.workspaceHandle,