浏览代码

fix: fix graphql history sync issue

Andrew Bastin 4 年之前
父节点
当前提交
503a54fc5e
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      packages/hoppscotch-app/helpers/fb/history.ts

+ 10 - 4
packages/hoppscotch-app/helpers/fb/history.ts

@@ -68,10 +68,13 @@ const purgeFormDataFromRequest = (req: RESTHistoryEntry): RESTHistoryEntry => {
 }
 
 async function writeHistory(
-  entry: RESTHistoryEntry,
+  entry: RESTHistoryEntry | GQLHistoryEntry,
   col: HistoryFBCollections
 ) {
-  const processedEntry = purgeFormDataFromRequest(entry)
+  const processedEntry =
+    col === "history"
+      ? purgeFormDataFromRequest(entry as RESTHistoryEntry)
+      : entry
 
   if (currentUser$.value == null)
     throw new Error("User not logged in to sync history")
@@ -93,7 +96,7 @@ async function writeHistory(
 }
 
 async function deleteHistory(
-  entry: RESTHistoryEntry & { id: string },
+  entry: (RESTHistoryEntry | GQLHistoryEntry) & { id: string },
   col: HistoryFBCollections
 ) {
   if (currentUser$.value == null)
@@ -120,7 +123,10 @@ async function clearHistory(col: HistoryFBCollections) {
   await Promise.all(docs.map((e) => deleteHistory(e as any, col)))
 }
 
-async function toggleStar(entry: any, col: HistoryFBCollections) {
+async function toggleStar(
+  entry: (RESTHistoryEntry | GQLHistoryEntry) & { id: string },
+  col: HistoryFBCollections
+) {
   if (currentUser$.value == null)
     throw new Error("User not logged in to toggle star")