From 503a54fc5ec8b7065dd4580e0907265fdb824f9b Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Fri, 12 Nov 2021 22:00:51 +0530 Subject: [PATCH] fix: fix graphql history sync issue --- packages/hoppscotch-app/helpers/fb/history.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/hoppscotch-app/helpers/fb/history.ts b/packages/hoppscotch-app/helpers/fb/history.ts index cbaf5aeae..d7b1207b3 100644 --- a/packages/hoppscotch-app/helpers/fb/history.ts +++ b/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")