diff --git a/packages/desktop/src/components/Terminal.tsx b/packages/desktop/src/components/Terminal.tsx index a58c746..122fc7c 100644 --- a/packages/desktop/src/components/Terminal.tsx +++ b/packages/desktop/src/components/Terminal.tsx @@ -128,9 +128,22 @@ export function TerminalProvider({ children }: { children?: React.ReactNode }) { console.log('got new or updated conversations', conversations); - updateConversationMap((draft) => { - conversations.forEach((convo) => { - draft[convo.id] = convo; + querySnapshot.docChanges().forEach((docChange) => { + updateConversationMap((draft) => { + const currentConversation = docChange.doc.data(); + + if (docChange.type === 'added') { + console.log('New conversation: ', currentConversation); + draft[currentConversation.id] = currentConversation; + } + if (docChange.type === 'modified') { + console.log('Modified conversation: ', currentConversation); + draft[currentConversation.id] = currentConversation; + } + if (docChange.type === 'removed') { + console.log('Removed conversation: ', currentConversation); + delete draft[currentConversation.id]; + } }); }); @@ -585,7 +598,7 @@ function ListConversations({ lookingForSomeone = false }: { lookingForSomeone: b - Inbox } - > + > */} ); } @@ -620,6 +633,8 @@ function ConversationRow({ conversation }: { conversation: Conversation }) { return; }, [conversation.memberIdsList, getUser, user, setConversationUsers]); + console.log(conversationUsers); + return (