mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 16:56:22 +02:00
refactor: enhance chat functionality with query invalidation and navigation improvements
- Integrated useQueryClient from React Query to manage query invalidation for threads, ensuring real-time updates in the sidebar when a new chat is created or a thread is deleted. - Updated the AllChatsSidebar to close the sidebar and navigate to the new chat page if the currently open chat is deleted. - Improved error handling and user experience during thread deletion by ensuring the sidebar closes smoothly before redirection.
This commit is contained in:
parent
d9df63f57e
commit
287fc236ad
3 changed files with 36 additions and 4 deletions
|
|
@ -149,6 +149,8 @@ export function AppSidebarProvider({
|
|||
await deleteThread(threadToDelete.id);
|
||||
// Invalidate threads query to refresh the list
|
||||
queryClient.invalidateQueries({ queryKey: ["threads", searchSpaceId] });
|
||||
// Navigate to new-chat after successful deletion
|
||||
router.push(`/dashboard/${searchSpaceId}/new-chat`);
|
||||
} catch (error) {
|
||||
console.error("Error deleting thread:", error);
|
||||
} finally {
|
||||
|
|
@ -156,7 +158,7 @@ export function AppSidebarProvider({
|
|||
setShowDeleteDialog(false);
|
||||
setThreadToDelete(null);
|
||||
}
|
||||
}, [threadToDelete, queryClient, searchSpaceId]);
|
||||
}, [threadToDelete, queryClient, searchSpaceId, router]);
|
||||
|
||||
// Handle delete note with confirmation
|
||||
const handleDeleteNote = useCallback(async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue