Browse Source

fix: ensure request name updates reflect immediately on the tabs

jamesgeorge007 10 months ago
parent
commit
58fcb2c4d0

+ 11 - 4
packages/hoppscotch-common/src/components/new-collections/rest/index.vue

@@ -1267,6 +1267,15 @@ const onEditRequest = async (newRequestName: string) => {
     return
   }
 
+  const possibleTab = tabs.getTabRefWithSaveContext({
+    originLocation: "workspace-user-collection",
+    requestHandle,
+  })
+
+  if (possibleTab) {
+    possibleTab.value.document.isDirty = false
+  }
+
   displayModalEditRequest(false)
   toast.success(t("request.renamed"))
 }
@@ -1692,13 +1701,11 @@ const dropRequest = async (payload: {
 
   const { auth, headers } = cascadingAuthHeadersHandle.value.data
 
-  const { providerID, requestID, workspaceID } = requestHandle.value.data
+  const { providerID, workspaceID } = requestHandle.value.data
 
   const possibleTab = tabs.getTabRefWithSaveContext({
     originLocation: "workspace-user-collection",
-    workspaceID,
-    providerID,
-    requestID,
+    requestHandle,
   })
 
   // If there is a tab attached to this request, update its save context

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

@@ -457,7 +457,7 @@ export class PersonalWorkspaceProviderService
       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
+          this.issuedHandles[idx].value.data.request.name = newRequest.name
         }
       }
     }