Open
Description
I have a collection of conversations. The conversation class contains a property which is a collection of ChatMessages, which contains its own properties.
here is my oode currently:
const conversationRef = query(collection(firestore, `/Conversations`));
const conversationQuery = useFirestoreQueryData(["Conversations", user.data?.uid], conversationRef,{
idField: "_id",
subscribe:true
})
function getConversations(){
const snapshot = conversationQuery.data;
if (snapshot){
const conversationArray:ActiveConversation[] = snapshot.map((snapshot) => {
const conversation:ActiveConversation = {
id: snapshot._id,
topic: snapshot.topic,
description: snapshot.description,
currentMessageInputValue: '',
chatMessages: [], //want to then query this as well.
isLoaded: false,
members: snapshot.members,
isConcluded: snapshot.isConcluded,
}
return conversation;
})
setActiveConversations(conversationArray);
}
}
useEffect(() => {
getConversations();
},[conversationQuery.data]);
Metadata
Assignees
Labels
No labels