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
fix: history entries becoming undefined over reloads
Andrew Bastinf20fed444a79
diff --git a/components/history/index.vue b/components/history/index.vueindex ce80e6471..2cf95471f 100644--- a/components/history/index.vue+++ b/components/history/index.vue@@ -144,7 +144,7 @@ export default defineComponent({})},useHistory(entry: any) {- if (this.page === "rest") setRESTRequest(entry)+ if (this.page === "rest") setRESTRequest(entry.request)},deleteHistory(entry: any) {if (this.page === "rest") deleteRESTHistoryEntry(entry)diff --git a/newstore/history.ts b/newstore/history.tsindex c776c9474..47f050dd1 100644--- a/newstore/history.ts+++ b/newstore/history.ts@@ -8,6 +8,8 @@ import {} from "~/helpers/types/HoppRESTRequest"export type RESTHistoryEntry = {+ v: number+request: HoppRESTRequestresponseMeta: {@@ -20,13 +22,26 @@ export type RESTHistoryEntry = {id?: string // For when Firebase Firestore is set}+export function makeHistoryEntry(+ x: Omit<RESTHistoryEntry, "v">+): RESTHistoryEntry {+ return {+ v: 1,+ ...x,+ }+}+export function translateToNewRESTHistory(x: any): RESTHistoryEntry {+ if (x.v === 1) return x++ // Legacyconst request = translateToNewRequest(x)const star = x.star ?? falseconst duration = x.duration ?? nullconst statusCode = x.status ?? nullconst obj: RESTHistoryEntry = {+ v: 1,request,star,responseMeta: {@@ -222,13 +237,15 @@ completedRESTResponse$.subscribe((res) => {if (res !== null) {if (res.type === "loading" || res.type === "network_fail") return- addRESTHistoryEntry({- request: res.req,- responseMeta: {- duration: res.meta.responseDuration,- statusCode: res.statusCode,- },- star: false,- })+ addRESTHistoryEntry(+ makeHistoryEntry({+ request: res.req,+ responseMeta: {+ duration: res.meta.responseDuration,+ statusCode: res.statusCode,+ },+ star: false,+ })+ )}})