mirror of
https://github.com/yusufipk/YTChatHub.git
synced 2026-09-11 10:56:17 +00:00
feat: add toggle behavior to message selection in dashboard
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user