fixing quering and updating logic
This commit is contained in:
@@ -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
|
||||
|
||||
<Divider />
|
||||
|
||||
<List
|
||||
{/* <List
|
||||
sx={{
|
||||
pt: 2,
|
||||
}}
|
||||
@@ -595,7 +608,7 @@ function ListConversations({ lookingForSomeone = false }: { lookingForSomeone: b
|
||||
<Typography variant="subtitle2"> Inbox</Typography>
|
||||
</ListSubheader>
|
||||
}
|
||||
></List>
|
||||
></List> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -620,6 +633,8 @@ function ConversationRow({ conversation }: { conversation: Conversation }) {
|
||||
return;
|
||||
}, [conversation.memberIdsList, getUser, user, setConversationUsers]);
|
||||
|
||||
console.log(conversationUsers);
|
||||
|
||||
return (
|
||||
<ListItem key={`${conversation.id}-priorityConvoList`}>
|
||||
<ListItemButton
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import React from 'react';
|
||||
|
||||
import Conversation from '@nirvana/core/src/models/conversation.model';
|
||||
|
||||
/**
|
||||
* if there is a name in the conversation, then return that
|
||||
* if not, then return first three names
|
||||
*/
|
||||
export default function ConversationLabel({ conversation }: { conversation: Conversation }) {
|
||||
// if (conversation.memberIdsList?.length === 2) {
|
||||
|
||||
// }
|
||||
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user