Browse Source

refactor: convey updates via handle mutation for update request action

jamesgeorge007 10 months ago
parent
commit
f358468a18

+ 0 - 19
packages/hoppscotch-common/src/components/new-collections/rest/index.vue

@@ -1267,25 +1267,6 @@ const onEditRequest = async (newRequestName: string) => {
     return
   }
 
-  const { providerID, workspaceID } = requestHandle.value.data
-
-  const possibleActiveTab = tabs.getTabRefWithSaveContext({
-    originLocation: "workspace-user-collection",
-    workspaceID,
-    providerID,
-    requestID,
-  })
-
-  if (possibleActiveTab) {
-    possibleActiveTab.value.document.request = {
-      ...possibleActiveTab.value.document.request,
-      name: newRequestName,
-    }
-    nextTick(() => {
-      possibleActiveTab.value.document.isDirty = false
-    })
-  }
-
   displayModalEditRequest(false)
   toast.success(t("request.renamed"))
 }

+ 11 - 0
packages/hoppscotch-common/src/services/new-workspace/providers/personal.workspace.ts

@@ -449,6 +449,17 @@ export class PersonalWorkspaceProviderService
       workspaceType: "personal",
     })
 
+    for (const [idx, handle] of this.issuedHandles.entries()) {
+      if (handle.value.type === "invalid") continue
+
+      if ("requestID" in handle.value.data) {
+        if (handle.value.data.requestID === requestID) {
+          // @ts-expect-error - We're updating the request data
+          this.issuedHandles[idx].value.data.request = newRequest
+        }
+      }
+    }
+
     return Promise.resolve(E.right(undefined))
   }