Merge pull request #17 from ArnasDon/fix/inbox-reclick-clears-messages

fix(inbox): re-clicking active conversation no longer clears messages
This commit is contained in:
Arnas Donauskas 2026-04-16 22:14:05 +03:00 committed by GitHub
commit 3615e8cacf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -139,11 +139,19 @@ export default function InboxPage() {
[]
);
const handleSelectConversation = useCallback((conv: Conversation) => {
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);