Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: catch an edge case while saving request

liyasthomase7535d505ee8
diff --git a/packages/hoppscotch-app/components/http/Request.vue b/packages/hoppscotch-app/components/http/Request.vue
index 5423265db..646a9ea5b 100644
--- a/packages/hoppscotch-app/components/http/Request.vue
+++ b/packages/hoppscotch-app/components/http/Request.vue
@@ -198,6 +198,7 @@ import {
getRESTSaveContext,
getRESTRequest,
restRequest$,
+ setRESTSaveContext,
} from "~/newstore/RESTSession"
import { editRESTRequest } from "~/newstore/collections"
import { runRESTRequest$ } from "~/helpers/RequestRunner"
@@ -418,8 +419,17 @@ const saveRequest = () => {
}
if (saveCtx.originLocation === "user-collection") {
- editRESTRequest(saveCtx.folderPath, saveCtx.requestIndex, getRESTRequest())
- toast.success(`${t("request.saved")}`)
+ try {
+ editRESTRequest(
+ saveCtx.folderPath,
+ saveCtx.requestIndex,
+ getRESTRequest()
+ )
+ toast.success(`${t("request.saved")}`)
+ } catch (e) {
+ setRESTSaveContext(null)
+ saveRequest()
+ }
} else if (saveCtx.originLocation === "team-collection") {
const req = getRESTRequest()
diff --git a/packages/hoppscotch-app/components/smart/Modal.vue b/packages/hoppscotch-app/components/smart/Modal.vue
index 147310d9c..f0f8a0d8b 100644
--- a/packages/hoppscotch-app/components/smart/Modal.vue
+++ b/packages/hoppscotch-app/components/smart/Modal.vue
@@ -73,7 +73,7 @@
</template>
<script lang="ts">
-import { defineComponent } from "@nuxtjs/composition-api"
+import { defineComponent, onBeforeUnmount } from "@nuxtjs/composition-api"
import { useKeybindingDisabler } from "~/helpers/keybindings"
const PORTAL_DOM_ID = "hoppscotch-modal-portal"
@@ -118,9 +118,12 @@ export default defineComponent({
setup() {
const { disableKeybindings, enableKeybindings } = useKeybindingDisabler()
+ onBeforeUnmount(() => {
+ enableKeybindings()
+ })
+
return {
disableKeybindings,
- enableKeybindings,
}
},
data() {
@@ -154,7 +157,6 @@ export default defineComponent({
methods: {
close() {
this.$emit("close")
- this.enableKeybindings()
},
onKeyDown(e: KeyboardEvent) {
if (e.key === "Escape" && this.stackId === stack.peek()) {
diff --git a/packages/hoppscotch-app/newstore/collections.ts b/packages/hoppscotch-app/newstore/collections.ts
index 12c1d9b37..5147cd8b1 100644
--- a/packages/hoppscotch-app/newstore/collections.ts
+++ b/packages/hoppscotch-app/newstore/collections.ts
@@ -744,6 +744,12 @@ export function editRESTRequest(
requestIndex: number,
requestNew: HoppRESTRequest
) {
+ const indexPaths = path.split("/").map((x) => parseInt(x))
+ if (
+ !navigateToFolderWithIndexPath(restCollectionStore.value.state, indexPaths)
+ )
+ throw new Error("Path not found")
+
restCollectionStore.dispatch({
dispatcher: "editRequest",
payload: {