Skip to content

Commit

Permalink
fix: confirmation button disappear
Browse files Browse the repository at this point in the history
  • Loading branch information
hahahumble committed May 15, 2023
1 parent a36bc39 commit e39f9e6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/Conversations/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,31 @@ function Sidebar({ notify }: SidebarProps) {
}
}

const deleteTimeoutRef = useRef<number | null>(null);

const handleDeleteClick = async (event: React.MouseEvent) => {
event.stopPropagation();
event.preventDefault();

if (!isConfirmingDelete) {
setIsConfirmingDelete(true);

setTimeout(() => {
if (deleteTimeoutRef.current !== null) {
clearTimeout(deleteTimeoutRef.current);
}

deleteTimeoutRef.current = window.setTimeout(() => {
setIsConfirmingDelete(false);
}, 6000);
} else {
clearSessions();
await chatDB.clearChats();
notify.allConversationClearNotify();
setIsConfirmingDelete(false);

if (deleteTimeoutRef.current !== null) {
clearTimeout(deleteTimeoutRef.current);
}
}
};

Expand Down

0 comments on commit e39f9e6

Please sign in to comment.