feat: loading indicator to fetch short code

This commit is contained in:
liyasthomas
2021-11-19 09:15:31 +05:30
parent 7d590ab966
commit f602a1e2d3

View File

@@ -170,6 +170,7 @@
ref="copyRequest" ref="copyRequest"
:label="shareLink ? shareLink : `${$t('request.copy_link')}`" :label="shareLink ? shareLink : `${$t('request.copy_link')}`"
:svg="copyLinkIcon" :svg="copyLinkIcon"
:loading="fetchingShareLink"
@click.native=" @click.native="
() => { () => {
copyRequest() copyRequest()
@@ -328,8 +329,11 @@ const clearContent = () => {
const copyLinkIcon = hasNavigatorShare ? ref("share-2") : ref("copy") const copyLinkIcon = hasNavigatorShare ? ref("share-2") : ref("copy")
const shareLink = ref("") const shareLink = ref("")
const fetchingShareLink = ref(false)
const copyRequest = () => { const copyRequest = () => {
fetchingShareLink.value = true
setTimeout(() => (fetchingShareLink.value = false), 1000)
shareLink.value = new URL(window.location.href).pathname shareLink.value = new URL(window.location.href).pathname
if (navigator.share) { if (navigator.share) {
@@ -349,7 +353,7 @@ const copyRequest = () => {
$toast.success(`${t("state.copied_to_clipboard")}`, { $toast.success(`${t("state.copied_to_clipboard")}`, {
icon: "content_paste", icon: "content_paste",
}) })
setTimeout(() => (copyLinkIcon.value = "copy"), 1000) setTimeout(() => (copyLinkIcon.value = "copy"), 2000)
} }
} }