feat: add toggle behavior to message selection in dashboard

This commit is contained in:
Yusuf İpek
2025-10-11 19:02:56 +03:00
parent fce6ca5708
commit 68d2f0f25c
+12 -6
View File
@@ -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 () => {