refactor: move Request.vue to composition api fully

This commit is contained in:
Andrew Bastin
2021-07-31 21:21:09 -04:00
parent 369bca90fc
commit 7354951d5a

View File

@@ -205,7 +205,7 @@ import { runRESTRequest$ } from "~/helpers/RequestRunner"
import { useStreamSubscriber, useStream } from "~/helpers/utils/composables" import { useStreamSubscriber, useStream } from "~/helpers/utils/composables"
import { defineActionHandler } from "~/helpers/actions" import { defineActionHandler } from "~/helpers/actions"
import { copyToClipboard } from "~/helpers/utils/clipboard" import { copyToClipboard } from "~/helpers/utils/clipboard"
import { getSettingSubject } from "~/newstore/settings" import { useSetting } from "~/newstore/settings"
const methods = [ const methods = [
"GET", "GET",
@@ -240,6 +240,8 @@ export default defineComponent({
const hasNavigatorShare = !!navigator.share const hasNavigatorShare = !!navigator.share
const options = ref<Vue | null>(null)
const newSendRequest = () => { const newSendRequest = () => {
loading.value = true loading.value = true
@@ -271,6 +273,12 @@ export default defineComponent({
updateRESTMethod(method) updateRESTMethod(method)
} }
const onSelectMethod = (method: string) => {
updateMethod(method)
// Vue-tippy has no typescript support yet
;(options.value as any).tippy().hide()
}
const clearContent = () => { const clearContent = () => {
resetRESTRequest() resetRESTRequest()
} }
@@ -353,20 +361,11 @@ export default defineComponent({
updateMethod, updateMethod,
clearContent, clearContent,
copyRequest, copyRequest,
} onSelectMethod,
},
methods: { EXPERIMENTAL_URL_BAR_ENABLED: useSetting("EXPERIMENTAL_URL_BAR_ENABLED"),
onSelectMethod(method: string) {
this.updateMethod(method) options,
// Something weird with prettier
;(this.$refs.options as any).tippy().hide()
},
},
subscriptions() {
return {
EXPERIMENTAL_URL_BAR_ENABLED: getSettingSubject(
"EXPERIMENTAL_URL_BAR_ENABLED"
),
} }
}, },
}) })