diff --git a/packages/hoppscotch-app/components/app/DeveloperOptions.vue b/packages/hoppscotch-app/components/app/DeveloperOptions.vue index a75d80ac0..4f5e06a7c 100644 --- a/packages/hoppscotch-app/components/app/DeveloperOptions.vue +++ b/packages/hoppscotch-app/components/app/DeveloperOptions.vue @@ -22,7 +22,7 @@ diff --git a/packages/hoppscotch-app/components/graphql/Sidebar.vue b/packages/hoppscotch-app/components/graphql/Sidebar.vue index aa8c8d86b..d7b2b293d 100644 --- a/packages/hoppscotch-app/components/graphql/Sidebar.vue +++ b/packages/hoppscotch-app/components/graphql/Sidebar.vue @@ -193,6 +193,7 @@ import { computed, nextTick, reactive, ref } from "@nuxtjs/composition-api" import { GraphQLField, GraphQLType } from "graphql" import { map } from "rxjs/operators" import { GQLHeader } from "@hoppscotch/data" +import { refAutoReset } from "@vueuse/core" import { useCodemirror } from "~/helpers/editor/codemirror" import { GQLConnection } from "~/helpers/GQLConnection" import { copyToClipboard } from "~/helpers/utils/clipboard" @@ -306,8 +307,8 @@ const graphqlTypes = useReadonlyStream( [] ) -const downloadSchemaIcon = ref("download") -const copySchemaIcon = ref("copy") +const downloadSchemaIcon = refAutoReset<"download" | "check">("download", 1000) +const copySchemaIcon = refAutoReset<"copy" | "check">("copy", 1000) const graphqlFieldsFilterText = ref("") @@ -423,7 +424,6 @@ const downloadSchema = () => { setTimeout(() => { document.body.removeChild(a) URL.revokeObjectURL(url) - downloadSchemaIcon.value = "download" }, 1000) } @@ -432,7 +432,6 @@ const copySchema = () => { copyToClipboard(schemaString.value) copySchemaIcon.value = "check" - setTimeout(() => (copySchemaIcon.value = "copy"), 1000) } const handleUseHistory = (entry: GQLHistoryEntry) => { diff --git a/packages/hoppscotch-app/components/http/CodegenModal.vue b/packages/hoppscotch-app/components/http/CodegenModal.vue index cc522f38b..b74a21ace 100644 --- a/packages/hoppscotch-app/components/http/CodegenModal.vue +++ b/packages/hoppscotch-app/components/http/CodegenModal.vue @@ -87,6 +87,7 @@ import { computed, ref, watch } from "@nuxtjs/composition-api" import * as O from "fp-ts/Option" import { Environment, makeRESTRequest } from "@hoppscotch/data" +import { refAutoReset } from "@vueuse/core" import { useCodemirror } from "~/helpers/editor/codemirror" import { copyToClipboard } from "~/helpers/utils/clipboard" import { @@ -118,9 +119,10 @@ const options = ref(null) const request = ref(getRESTRequest()) const codegenType = ref("shell-curl") -const copyIcon = ref("copy") const errorState = ref(false) +const copyIcon = refAutoReset<"copy" | "check">("copy", 1000) + const requestCode = computed(() => { const aggregateEnvs = getAggregateEnvs() const env: Environment = { @@ -184,7 +186,6 @@ const copyRequestCode = () => { copyToClipboard(requestCode.value) copyIcon.value = "check" toast.success(`${t("state.copied_to_clipboard")}`) - setTimeout(() => (copyIcon.value = "copy"), 1000) } const searchQuery = ref("") diff --git a/packages/hoppscotch-app/components/http/ImportCurl.vue b/packages/hoppscotch-app/components/http/ImportCurl.vue index 671643879..8d27877c7 100644 --- a/packages/hoppscotch-app/components/http/ImportCurl.vue +++ b/packages/hoppscotch-app/components/http/ImportCurl.vue @@ -39,6 +39,7 @@ diff --git a/packages/hoppscotch-app/components/http/Request.vue b/packages/hoppscotch-app/components/http/Request.vue index 5efeb2231..d2d1b1385 100644 --- a/packages/hoppscotch-app/components/http/Request.vue +++ b/packages/hoppscotch-app/components/http/Request.vue @@ -215,6 +215,7 @@ import { computed, ref, watch } from "@nuxtjs/composition-api" import { isLeft, isRight } from "fp-ts/lib/Either" import * as E from "fp-ts/Either" import cloneDeep from "lodash/cloneDeep" +import { refAutoReset } from "@vueuse/core" import { updateRESTResponse, restEndpoint$, @@ -393,7 +394,11 @@ const clearContent = () => { resetRESTRequest() } -const copyLinkIcon = hasNavigatorShare ? ref("share-2") : ref("copy") +const copyLinkIcon = refAutoReset<"share-2" | "copy" | "check">( + hasNavigatorShare ? "share-2" : "copy", + 1000 +) + const shareLink = ref("") const fetchingShareLink = ref(false) @@ -448,7 +453,6 @@ const copyShareLink = (shareLink: string) => { copyLinkIcon.value = "check" copyToClipboard(`https://hopp.sh/r${shareLink}`) toast.success(`${t("state.copied_to_clipboard")}`) - setTimeout(() => (copyLinkIcon.value = "copy"), 2000) } } diff --git a/packages/hoppscotch-app/components/lenses/HeadersRenderer.vue b/packages/hoppscotch-app/components/lenses/HeadersRenderer.vue index 448fc8a86..b238145e6 100644 --- a/packages/hoppscotch-app/components/lenses/HeadersRenderer.vue +++ b/packages/hoppscotch-app/components/lenses/HeadersRenderer.vue @@ -26,8 +26,8 @@ diff --git a/packages/hoppscotch-app/components/lenses/HeadersRendererEntry.vue b/packages/hoppscotch-app/components/lenses/HeadersRendererEntry.vue index 3c6c33292..70c075cab 100644 --- a/packages/hoppscotch-app/components/lenses/HeadersRendererEntry.vue +++ b/packages/hoppscotch-app/components/lenses/HeadersRendererEntry.vue @@ -28,7 +28,7 @@ diff --git a/packages/hoppscotch-app/components/profile/Shortcode.vue b/packages/hoppscotch-app/components/profile/Shortcode.vue index ec2a90804..3fd1f8c00 100644 --- a/packages/hoppscotch-app/components/profile/Shortcode.vue +++ b/packages/hoppscotch-app/components/profile/Shortcode.vue @@ -65,6 +65,7 @@ import { pipe } from "fp-ts/function" import * as RR from "fp-ts/ReadonlyRecord" import * as O from "fp-ts/Option" import { translateToNewRequest } from "@hoppscotch/data" +import { refAutoReset } from "@vueuse/core" import { useI18n, useToast } from "~/helpers/utils/composables" import { copyToClipboard } from "~/helpers/utils/clipboard" import { Shortcode } from "~/helpers/shortcodes/Shortcode" @@ -93,7 +94,8 @@ const requestMethodLabels = { } as const const timeStampRef = ref() -const copyIconRefs = ref<"copy" | "check">("copy") + +const copyIconRefs = refAutoReset<"copy" | "check">("copy", 1000) const parseShortcodeRequest = computed(() => pipe(props.shortcode.request, JSON.parse, translateToNewRequest) @@ -118,7 +120,6 @@ const copyShortcode = (codeID: string) => { copyToClipboard(`https://hopp.sh/r/${codeID}`) toast.success(`${t("state.copied_to_clipboard")}`) copyIconRefs.value = "check" - setTimeout(() => (copyIconRefs.value = "copy"), 1000) } diff --git a/packages/hoppscotch-app/components/realtime/Communication.vue b/packages/hoppscotch-app/components/realtime/Communication.vue index b96a634f2..1eebd452f 100644 --- a/packages/hoppscotch-app/components/realtime/Communication.vue +++ b/packages/hoppscotch-app/components/realtime/Communication.vue @@ -113,6 +113,7 @@ import { computed, reactive, ref } from "@nuxtjs/composition-api" import { pipe } from "fp-ts/function" import * as TO from "fp-ts/TaskOption" import * as O from "fp-ts/Option" +import { refAutoReset } from "@vueuse/core" import { useCodemirror } from "~/helpers/editor/codemirror" import jsonLinter from "~/helpers/editor/linting/json" import { readFileAsText } from "~/helpers/functional/files" @@ -145,7 +146,8 @@ const toast = useToast() const linewrapEnabled = ref(true) const wsCommunicationBody = ref() -const prettifyIcon = ref<"wand" | "check" | "info">("wand") + +const prettifyIcon = refAutoReset<"wand" | "check" | "info">("wand", 1000) const knownContentTypes = { JSON: "application/ld+json", @@ -216,6 +218,5 @@ const prettifyRequestBody = () => { prettifyIcon.value = "info" toast.error(`${t("error.json_prettify_invalid_body")}`) } - setTimeout(() => (prettifyIcon.value = "wand"), 1000) } diff --git a/packages/hoppscotch-app/components/realtime/LogEntry.vue b/packages/hoppscotch-app/components/realtime/LogEntry.vue index 56a8537b7..f11854395 100644 --- a/packages/hoppscotch-app/components/realtime/LogEntry.vue +++ b/packages/hoppscotch-app/components/realtime/LogEntry.vue @@ -203,7 +203,7 @@ import * as LJSON from "lossless-json" import * as O from "fp-ts/Option" import { pipe } from "fp-ts/function" import { ref, computed, reactive, watch } from "@nuxtjs/composition-api" -import { useTimeAgo } from "@vueuse/core" +import { refAutoReset, useTimeAgo } from "@vueuse/core" import { LogEntryData } from "./Log.vue" import { useI18n } from "~/helpers/utils/composables" import { copyToClipboard } from "~/helpers/utils/clipboard" @@ -310,11 +310,11 @@ const { downloadIcon, downloadResponse } = useDownloadResponse( logPayload ) -const copyQueryIcon = ref("copy") +const copyQueryIcon = refAutoReset<"copy" | "check">("copy", 1000) + const copyQuery = (entry: string) => { copyToClipboard(entry) copyQueryIcon.value = "check" - setTimeout(() => (copyQueryIcon.value = "copy"), 1000) } // Relative Time diff --git a/packages/hoppscotch-app/helpers/lenses/composables/useCopyResponse.ts b/packages/hoppscotch-app/helpers/lenses/composables/useCopyResponse.ts index bad75c68f..a7ca65917 100644 --- a/packages/hoppscotch-app/helpers/lenses/composables/useCopyResponse.ts +++ b/packages/hoppscotch-app/helpers/lenses/composables/useCopyResponse.ts @@ -1,4 +1,5 @@ -import { Ref, ref } from "@nuxtjs/composition-api" +import { Ref } from "@nuxtjs/composition-api" +import { refAutoReset } from "@vueuse/core" import { copyToClipboard } from "~/helpers/utils/clipboard" import { useI18n, useToast } from "~/helpers/utils/composables" @@ -8,13 +9,13 @@ export default function useCopyResponse(responseBodyText: Ref): { } { const toast = useToast() const t = useI18n() - const copyIcon = ref("copy") + + const copyIcon = refAutoReset<"copy" | "check">("copy", 1000) const copyResponse = () => { copyToClipboard(responseBodyText.value) copyIcon.value = "check" toast.success(`${t("state.copied_to_clipboard")}`) - setTimeout(() => (copyIcon.value = "copy"), 1000) } return { diff --git a/packages/hoppscotch-app/helpers/lenses/composables/useDownloadResponse.ts b/packages/hoppscotch-app/helpers/lenses/composables/useDownloadResponse.ts index 95a070169..8e9582b27 100644 --- a/packages/hoppscotch-app/helpers/lenses/composables/useDownloadResponse.ts +++ b/packages/hoppscotch-app/helpers/lenses/composables/useDownloadResponse.ts @@ -1,7 +1,8 @@ import * as S from "fp-ts/string" import * as RNEA from "fp-ts/ReadonlyNonEmptyArray" import { pipe } from "fp-ts/function" -import { Ref, ref } from "@nuxtjs/composition-api" +import { Ref } from "@nuxtjs/composition-api" +import { refAutoReset } from "@vueuse/core" import { useI18n, useToast } from "~/helpers/utils/composables" export type downloadResponseReturnType = (() => void) | Ref @@ -13,7 +14,8 @@ export default function useDownloadResponse( downloadIcon: Ref downloadResponse: () => void } { - const downloadIcon = ref("download") + const downloadIcon = refAutoReset<"download" | "check">("download", 1000) + const toast = useToast() const t = useI18n() @@ -42,7 +44,6 @@ export default function useDownloadResponse( setTimeout(() => { document.body.removeChild(a) URL.revokeObjectURL(url) - downloadIcon.value = "download" }, 1000) } return { diff --git a/packages/hoppscotch-app/pages/settings.vue b/packages/hoppscotch-app/pages/settings.vue index 78f9df3c3..7e482e4c6 100644 --- a/packages/hoppscotch-app/pages/settings.vue +++ b/packages/hoppscotch-app/pages/settings.vue @@ -236,6 +236,7 @@