From 68d2f0f25c308d3a0af49e88b764a79554dabd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yusuf=20=C4=B0pek?= Date: Sat, 11 Oct 2025 19:02:56 +0300 Subject: [PATCH] feat: add toggle behavior to message selection in dashboard --- client/app/dashboard/page.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/client/app/dashboard/page.tsx b/client/app/dashboard/page.tsx index 0c728e4..816e86c 100644 --- a/client/app/dashboard/page.tsx +++ b/client/app/dashboard/page.tsx @@ -18,16 +18,22 @@ export default function DashboardPage() { const handleSelect = useCallback( async (message: ChatMessage) => { try { - await fetch(`${BACKEND_URL}/overlay/selection`, { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ id: message.id }) - }); + // If clicking the already-selected message, clear it + if (selection?.id === message.id) { + await fetch(`${BACKEND_URL}/overlay/selection`, { method: 'DELETE' }); + } else { + // Otherwise, select the new message + await fetch(`${BACKEND_URL}/overlay/selection`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ id: message.id }) + }); + } } catch (error) { console.error('Failed to select message', error); } }, - [] + [selection] ); const handleClear = useCallback(async () => {