fix: clear issue copy timer between clicks
This commit is contained in:
parent
3ffa94ab52
commit
1c7a8246b5
1 changed files with 16 additions and 1 deletions
|
|
@ -210,6 +210,7 @@ export function IssueDetail() {
|
||||||
});
|
});
|
||||||
const [attachmentError, setAttachmentError] = useState<string | null>(null);
|
const [attachmentError, setAttachmentError] = useState<string | null>(null);
|
||||||
const [attachmentDragActive, setAttachmentDragActive] = useState(false);
|
const [attachmentDragActive, setAttachmentDragActive] = useState(false);
|
||||||
|
const copiedTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
||||||
const lastMarkedReadIssueIdRef = useRef<string | null>(null);
|
const lastMarkedReadIssueIdRef = useRef<string | null>(null);
|
||||||
|
|
||||||
|
|
@ -590,6 +591,14 @@ export function IssueDetail() {
|
||||||
return () => closePanel();
|
return () => closePanel();
|
||||||
}, [issue]); // eslint-disable-line react-hooks/exhaustive-deps
|
}, [issue]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
if (copiedTimerRef.current !== null) {
|
||||||
|
clearTimeout(copiedTimerRef.current);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const copyIssueToClipboard = async () => {
|
const copyIssueToClipboard = async () => {
|
||||||
if (!issue) return;
|
if (!issue) return;
|
||||||
const decodeEntities = (text: string) => {
|
const decodeEntities = (text: string) => {
|
||||||
|
|
@ -603,7 +612,13 @@ export function IssueDetail() {
|
||||||
await navigator.clipboard.writeText(md);
|
await navigator.clipboard.writeText(md);
|
||||||
setCopied(true);
|
setCopied(true);
|
||||||
pushToast({ title: "Copied to clipboard", tone: "success" });
|
pushToast({ title: "Copied to clipboard", tone: "success" });
|
||||||
setTimeout(() => setCopied(false), 2000);
|
if (copiedTimerRef.current !== null) {
|
||||||
|
clearTimeout(copiedTimerRef.current);
|
||||||
|
}
|
||||||
|
copiedTimerRef.current = setTimeout(() => {
|
||||||
|
setCopied(false);
|
||||||
|
copiedTimerRef.current = null;
|
||||||
|
}, 2000);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLoading) return <p className="text-sm text-muted-foreground">Loading...</p>;
|
if (isLoading) return <p className="text-sm text-muted-foreground">Loading...</p>;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue