Browse Source

refactor: update gql properties sync

nivedin 1 year ago
parent
commit
83019733e3

+ 15 - 5
packages/hoppscotch-selfhost-web/src/platform/collections/gqlCollections.sync.ts

@@ -21,7 +21,7 @@ import {
   deleteUserCollection,
   deleteUserRequest,
   editGQLUserRequest,
-  renameUserCollection,
+  updateUserCollection,
 } from "./collections.api"
 
 import * as E from "fp-ts/Either"
@@ -158,8 +158,13 @@ export const storeSyncDefinition: StoreSyncDefinitionOf<
       [collectionIndex]
     )?.id
 
-    if (collectionID && collection.name) {
-      renameUserCollection(collectionID, collection.name)
+    const data = {
+      auth: collection.auth,
+      headers: collection.headers,
+    }
+
+    if (collectionID) {
+      updateUserCollection(collectionID, collection.name, JSON.stringify(data))
     }
   },
   async addFolder({ name, path }) {
@@ -197,8 +202,13 @@ export const storeSyncDefinition: StoreSyncDefinitionOf<
       path.split("/").map((index) => parseInt(index))
     )?.id
 
-    if (folderBackendId && folder.name) {
-      renameUserCollection(folderBackendId, folder.name)
+    const data = {
+      auth: folder.auth,
+      headers: folder.headers,
+    }
+
+    if (folderBackendId) {
+      updateUserCollection(folderBackendId, folder.name, JSON.stringify(data))
     }
   },
   async removeFolder({ folderID }) {