fix: tab system breaks when a new tab is created while waiting for response in another tab (#3031)
This commit is contained in:
@@ -136,11 +136,11 @@ const requestName = ref(
|
|||||||
)
|
)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [currentActiveTab.value.document.request.name, gqlRequestName.value],
|
() => [currentActiveTab.value, gqlRequestName.value],
|
||||||
() => {
|
() => {
|
||||||
if (props.mode === "rest")
|
if (props.mode === "rest") {
|
||||||
requestName.value = currentActiveTab.value.document.request.name
|
requestName.value = currentActiveTab.value?.document.request.name ?? ""
|
||||||
else requestName.value = gqlRequestName.value
|
} else requestName.value = gqlRequestName.value
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -229,11 +229,10 @@ import { useI18n } from "@composables/i18n"
|
|||||||
import { useSetting } from "@composables/settings"
|
import { useSetting } from "@composables/settings"
|
||||||
import { useStreamSubscriber } from "@composables/stream"
|
import { useStreamSubscriber } from "@composables/stream"
|
||||||
import { useToast } from "@composables/toast"
|
import { useToast } from "@composables/toast"
|
||||||
import { completePageProgress, startPageProgress } from "@modules/loadingbar"
|
|
||||||
import { refAutoReset, useVModel } from "@vueuse/core"
|
import { refAutoReset, useVModel } from "@vueuse/core"
|
||||||
import * as E from "fp-ts/Either"
|
import * as E from "fp-ts/Either"
|
||||||
import { isLeft, isRight } from "fp-ts/lib/Either"
|
import { isLeft, isRight } from "fp-ts/lib/Either"
|
||||||
import { computed, ref, watch } from "vue"
|
import { computed, onBeforeUnmount, ref } from "vue"
|
||||||
import { defineActionHandler } from "~/helpers/actions"
|
import { defineActionHandler } from "~/helpers/actions"
|
||||||
import { runMutation } from "~/helpers/backend/GQLClient"
|
import { runMutation } from "~/helpers/backend/GQLClient"
|
||||||
import { UpdateRequestDocument } from "~/helpers/backend/graphql"
|
import { UpdateRequestDocument } from "~/helpers/backend/graphql"
|
||||||
@@ -311,39 +310,6 @@ const clearAll = ref<any | null>(null)
|
|||||||
const copyRequestAction = ref<any | null>(null)
|
const copyRequestAction = ref<any | null>(null)
|
||||||
const saveRequestAction = ref<any | null>(null)
|
const saveRequestAction = ref<any | null>(null)
|
||||||
|
|
||||||
// Update Nuxt Loading bar
|
|
||||||
watch(loading, () => {
|
|
||||||
if (loading.value) {
|
|
||||||
startPageProgress()
|
|
||||||
} else {
|
|
||||||
completePageProgress()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// TODO: make this oAuthURL() work
|
|
||||||
|
|
||||||
// function oAuthURL() {
|
|
||||||
// const auth = useReadonlyStream(props.request.auth$, {
|
|
||||||
// authType: "none",
|
|
||||||
// authActive: true,
|
|
||||||
// })
|
|
||||||
|
|
||||||
// const oauth2Token = pluckRef(auth as Ref<HoppRESTAuthOAuth2>, "token")
|
|
||||||
|
|
||||||
// onBeforeMount(async () => {
|
|
||||||
// try {
|
|
||||||
// const tokenInfo = await oauthRedirect()
|
|
||||||
// if (Object.prototype.hasOwnProperty.call(tokenInfo, "access_token")) {
|
|
||||||
// if (typeof tokenInfo === "object") {
|
|
||||||
// oauth2Token.value = tokenInfo.access_token
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // eslint-disable-next-line no-empty
|
|
||||||
// } catch (_) {}
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
const newSendRequest = async () => {
|
const newSendRequest = async () => {
|
||||||
if (newEndpoint.value === "" || /^\s+$/.test(newEndpoint.value)) {
|
if (newEndpoint.value === "" || /^\s+$/.test(newEndpoint.value)) {
|
||||||
toast.error(`${t("empty.endpoint")}`)
|
toast.error(`${t("empty.endpoint")}`)
|
||||||
@@ -574,6 +540,10 @@ const saveRequest = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
if (loading.value) cancelRequest()
|
||||||
|
})
|
||||||
|
|
||||||
defineActionHandler("request.send-cancel", () => {
|
defineActionHandler("request.send-cancel", () => {
|
||||||
if (!loading.value) newSendRequest()
|
if (!loading.value) newSendRequest()
|
||||||
else cancelRequest()
|
else cancelRequest()
|
||||||
|
|||||||
@@ -10,8 +10,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, watch } from "vue"
|
import { computed, ref } from "vue"
|
||||||
import { startPageProgress, completePageProgress } from "@modules/loadingbar"
|
|
||||||
import { HoppRESTTab } from "~/helpers/rest/tab"
|
import { HoppRESTTab } from "~/helpers/rest/tab"
|
||||||
import { useVModel } from "@vueuse/core"
|
import { useVModel } from "@vueuse/core"
|
||||||
|
|
||||||
@@ -34,9 +33,4 @@ const hasResponse = computed(
|
|||||||
)
|
)
|
||||||
|
|
||||||
const loading = computed(() => tab.value.response?.type === "loading")
|
const loading = computed(() => tab.value.response?.type === "loading")
|
||||||
|
|
||||||
watch(loading, (isLoading) => {
|
|
||||||
if (isLoading) startPageProgress()
|
|
||||||
else completePageProgress()
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user