mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-01 05:26:53 +00:00
22 lines
564 B
TypeScript
22 lines
564 B
TypeScript
export function useIsCopied(timeoutInMs = 3000) {
|
|
let copiedTimeoutId: ReturnType<typeof setTimeout>
|
|
|
|
const isCopied = ref(false)
|
|
|
|
async function performCopy(copyCallback: () => void) {
|
|
if (copiedTimeoutId) clearTimeout(copiedTimeoutId)
|
|
try {
|
|
await copyCallback()
|
|
isCopied.value = true
|
|
copiedTimeoutId = setTimeout(() => {
|
|
isCopied.value = false
|
|
clearTimeout(copiedTimeoutId)
|
|
}, timeoutInMs)
|
|
} catch (e: any) {
|
|
if (e?.message) message.error(e.message)
|
|
}
|
|
}
|
|
|
|
return { isCopied, performCopy }
|
|
}
|