Formatting

This commit is contained in:
pierrbt
2023-06-23 01:39:22 +02:00
parent a9bb05c4da
commit 9be77826e9

View File

@@ -23,28 +23,27 @@ const showCompletedUploadModal = (
}); });
}; };
const Body = ({ share, appUrl }: { share: Share; appUrl: string }) => { const Body = ({ share, appUrl }: { share: Share; appUrl: string }) => {
const clipboard = useClipboard({ timeout: 500 }); const clipboard = useClipboard({ timeout: 500 });
const modals = useModals(); const modals = useModals();
const router = useRouter(); const router = useRouter();
const [checkState, setCheckState] = useState(false); const [checkState, setCheckState] = useState(false);
const timerRef = useRef<number | ReturnType<typeof setTimeout> | undefined>(undefined); const timerRef = useRef<number | ReturnType<typeof setTimeout> | undefined>(
undefined
);
const link = `${appUrl}/share/${share.id}`; const link = `${appUrl}/share/${share.id}`;
const copyLink = () => { const copyLink = () => {
clipboard.copy(link); clipboard.copy(link);
toast.success("Your link was copied to the keyboard."); toast.success("Your link was copied to the keyboard.");
if (timerRef.current) if (timerRef.current) clearTimeout(timerRef.current);
clearTimeout(timerRef.current);
timerRef.current = setTimeout(() => { timerRef.current = setTimeout(() => {
setCheckState(false); setCheckState(false);
}, 1500); }, 1500);
setCheckState(true); setCheckState(true);
} };
return ( return (
<Stack align="stretch"> <Stack align="stretch">
@@ -55,10 +54,8 @@ const Body = ({ share, appUrl }: { share: Share; appUrl: string }) => {
onClick={copyLink} onClick={copyLink}
rightSection={ rightSection={
window.isSecureContext && ( window.isSecureContext && (
<ActionIcon <ActionIcon onClick={copyLink}>
onClick={copyLink} {checkState ? <TbChecks /> : <TbCopy />}
>
{ checkState ? <TbChecks /> : <TbCopy /> }
</ActionIcon> </ActionIcon>
) )
} }