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);
|
console.log('got new or updated conversations', conversations);
|
||||||
|
|
||||||
updateConversationMap((draft) => {
|
querySnapshot.docChanges().forEach((docChange) => {
|
||||||
conversations.forEach((convo) => {
|
updateConversationMap((draft) => {
|
||||||
draft[convo.id] = convo;
|
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 />
|
<Divider />
|
||||||
|
|
||||||
<List
|
{/* <List
|
||||||
sx={{
|
sx={{
|
||||||
pt: 2,
|
pt: 2,
|
||||||
}}
|
}}
|
||||||
@@ -595,7 +608,7 @@ function ListConversations({ lookingForSomeone = false }: { lookingForSomeone: b
|
|||||||
<Typography variant="subtitle2"> Inbox</Typography>
|
<Typography variant="subtitle2"> Inbox</Typography>
|
||||||
</ListSubheader>
|
</ListSubheader>
|
||||||
}
|
}
|
||||||
></List>
|
></List> */}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -620,6 +633,8 @@ function ConversationRow({ conversation }: { conversation: Conversation }) {
|
|||||||
return;
|
return;
|
||||||
}, [conversation.memberIdsList, getUser, user, setConversationUsers]);
|
}, [conversation.memberIdsList, getUser, user, setConversationUsers]);
|
||||||
|
|
||||||
|
console.log(conversationUsers);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem key={`${conversation.id}-priorityConvoList`}>
|
<ListItem key={`${conversation.id}-priorityConvoList`}>
|
||||||
<ListItemButton
|
<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