diff --git a/web/src/components/ConversationList.tsx b/web/src/components/ConversationList.tsx index 8a658b4..7398f41 100644 --- a/web/src/components/ConversationList.tsx +++ b/web/src/components/ConversationList.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from "react"; +import { useNavigate } from "react-router-dom"; import { useConversationStore } from "../stores/conversation.ts"; import { useAuthStore } from "../stores/auth.ts"; import { NewConversationModal } from "./NewConversationModal.tsx"; @@ -16,30 +17,36 @@ export function ConversationList() { const conversations = useConversationStore((s) => s.conversations); const activeId = useConversationStore((s) => s.activeConversationId); const fetchConversations = useConversationStore((s) => s.fetchConversations); - const setActive = useConversationStore((s) => s.setActiveConversation); const createConversation = useConversationStore((s) => s.createConversation); const currentUser = useAuthStore((s) => s.user); + const navigate = useNavigate(); const [showNew, setShowNew] = useState(false); + const [notesError, setNotesError] = useState(null); useEffect(() => { fetchConversations(); }, [fetchConversations]); - const [notesError, setNotesError] = useState(null); + const openConversation = (convId: string) => { + navigate(`/dm/${convId}`); + }; const openNotes = async () => { setNotesError(null); // Find existing self-DM or create one const existing = conversations.find((c) => isSelfDM(c, currentUser?.id || "")); if (existing) { - setActive(existing.id); + navigate(`/dm/${existing.id}`); return; } try { - await createConversation([]); + const conv = await createConversation([]); + if (conv) { + navigate(`/dm/${conv.id}`); + } } catch (err) { - console.error('Failed to create notes:', err); - setNotesError(err instanceof Error ? err.message : 'Failed to create notes'); + console.error("Failed to create notes:", err); + setNotesError(err instanceof Error ? err.message : "Failed to create notes"); } }; @@ -78,7 +85,7 @@ export function ConversationList() { return (