Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
chore: add removeDuplicateEntry dispatcher to history store (#2955)
Akash Kdbb45e7253e6
diff --git a/packages/hoppscotch-common/src/newstore/history.ts b/packages/hoppscotch-common/src/newstore/history.tsindex 6943651c1..e4e5d53d9 100644--- a/packages/hoppscotch-common/src/newstore/history.ts+++ b/packages/hoppscotch-common/src/newstore/history.ts@@ -163,6 +163,20 @@ const RESTHistoryDispatchers = defineDispatchers({}),}},+ // only used for history.sync.ts to prevent double insertion of history entries from storeSync and Subscriptions+ removeDuplicateEntry(currentVal: RESTHistoryType, { id }: { id: string }) {+ const entries = currentVal.state.filter((e) => e.id === id)++ if (entries.length == 2) {+ const indexToRemove = currentVal.state.findIndex((e) => e.id === id)++ currentVal.state.splice(indexToRemove, 1)+ }++ return {+ state: currentVal.state,+ }+ },})const GQLHistoryDispatchers = defineDispatchers({@@ -212,6 +226,20 @@ const GQLHistoryDispatchers = defineDispatchers({}),}},+ // only used for history.sync.ts to prevent double insertion of history entries from storeSync and Subscriptions+ removeDuplicateEntry(currentVal: GraphqlHistoryType, { id }: { id: string }) {+ const entries = currentVal.state.filter((e) => e.id === id)++ if (entries.length == 2) {+ const indexToRemove = currentVal.state.findIndex((e) => e.id === id)++ currentVal.state.splice(indexToRemove, 1)+ }++ return {+ state: currentVal.state,+ }+ },})export const restHistoryStore = new DispatchingStore(@@ -297,6 +325,20 @@ export function toggleGraphqlHistoryEntryStar(entry: GQLHistoryEntry) {})}+export function removeDuplicateRestHistoryEntry(id: string) {+ restHistoryStore.dispatch({+ dispatcher: "removeDuplicateEntry",+ payload: { id },+ })+}++export function removeDuplicateGraphqlHistoryEntry(id: string) {+ graphqlHistoryStore.dispatch({+ dispatcher: "removeDuplicateEntry",+ payload: { id },+ })+}+// Listen to completed responses to add to historycompletedRESTResponse$.subscribe((res) => {if (res !== null) {