fix: catch an edge case while saving request
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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: {
|
||||
|
||||
Reference in New Issue
Block a user