fix(inbox): re-clicking active conversation no longer clears messages

Selecting the already-active conversation called setMessages([]) but the
fetch effect in MessageThread only re-runs when conversationId changes,
so messages stayed empty until the user left the page and came back.
Bail out of handleSelectConversation when the clicked conversation is
already active.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Arnas Donauskas 2026-04-16 22:11:57 +03:00
parent 0a9d9f2bb3
commit 5467c3e1e3
No known key found for this signature in database

View File

@ -139,11 +139,19 @@ export default function InboxPage() {
[]
);
const handleSelectConversation = useCallback((conv: Conversation) => {
setActiveConversation(conv);
setActiveContact(conv.contact ?? null);
setMessages([]);
}, []);
const handleSelectConversation = useCallback(
(conv: Conversation) => {
// Re-clicking the already-active conversation would clear the
// messages array, but the fetch effect in MessageThread only re-runs
// when conversationId changes — so messages would stay empty until
// the user navigated away and back. Bail out early instead.
if (activeConversation?.id === conv.id) return;
setActiveConversation(conv);
setActiveContact(conv.contact ?? null);
setMessages([]);
},
[activeConversation?.id]
);
const handleMessagesLoaded = useCallback((loaded: Message[]) => {
setMessages(loaded);