updating nicely

This commit is contained in:
Arjun Patel
2022-02-05 11:11:45 -08:00
parent a5df77123d
commit ac92e1dd10
2 changed files with 17 additions and 11 deletions
+15 -10
View File
@@ -79,7 +79,8 @@ export default class ConversationService {
async updateUserConvoRelationship( async updateUserConvoRelationship(
userId: string, userId: string,
convoId: string, convoId: string,
newState: ConversationMemberState newState: ConversationMemberState,
changeLastInteractionDate: boolean = true
) { ) {
const docRef = doc( const docRef = doc(
this.db, this.db,
@@ -88,14 +89,18 @@ export default class ConversationService {
Collections.conversationMembers, Collections.conversationMembers,
userId userId
); );
await setDoc(
docRef, const newUpdates = changeLastInteractionDate
{ ? {
state: newState, state: newState,
lastUpdatedDate: serverTimestamp(), lastUpdatedDate: serverTimestamp(),
lastInteractionDate: serverTimestamp(), lastInteractionDate: serverTimestamp(),
}, }
{ merge: true } : {
); state: newState,
lastUpdatedDate: serverTimestamp(),
};
await setDoc(docRef, newUpdates, { merge: true });
} }
} }
+2 -1
View File
@@ -181,7 +181,8 @@ export const doneConvosSelector = selector<Conversation[]>({
conversationService.updateUserConvoRelationship( conversationService.updateUserConvoRelationship(
userConvoAssoc.id, userConvoAssoc.id,
conv.id, conv.id,
ConversationMemberState.default ConversationMemberState.default,
false
); );
} }