refactor: add safety coersion for loading rest requests from external source

This commit is contained in:
Andrew Bastin
2022-01-05 16:15:06 +05:30
parent 137d562c86
commit ac979239e8
6 changed files with 73 additions and 23 deletions

View File

@@ -103,6 +103,7 @@
<script setup lang="ts">
import { computed, ref } from "@nuxtjs/composition-api"
import * as timeago from "timeago.js"
import { safelyExtractRESTRequest } from "~/../hoppscotch-data/dist"
import {
useI18n,
useReadonlyStream,
@@ -120,7 +121,7 @@ import {
RESTHistoryEntry,
GQLHistoryEntry,
} from "~/newstore/history"
import { setRESTRequest } from "~/newstore/RESTSession"
import { getDefaultRESTRequest, setRESTRequest } from "~/newstore/RESTSession"
const props = defineProps<{
page: "rest" | "graphql"
@@ -174,7 +175,10 @@ const clearHistory = () => {
}
const useHistory = (entry: any) => {
if (props.page === "rest") setRESTRequest(entry.request)
if (props.page === "rest")
setRESTRequest(
safelyExtractRESTRequest(entry.request, getDefaultRESTRequest())
)
}
const deleteBattleHistoryEntry = (entries: number[]) => {