joining and leaving backend side done and now agora test here we go

This commit is contained in:
Arjun Patel
2022-02-07 21:57:17 -08:00
parent 8d382f960a
commit 1bc7957824
8 changed files with 235 additions and 26 deletions
@@ -8,6 +8,8 @@ import {
setDoc,
runTransaction,
writeBatch,
arrayUnion,
arrayRemove,
} from "firebase/firestore";
import Conversation, {
AudioClip,
@@ -179,7 +181,33 @@ export default class ConversationService {
},
{ merge: true }
);
}
return false;
async joinLiveConversation(convoId: string, userJoiningId: string) {
// todo: make sure that user is part of the convo or valid in it
const docRef = doc(this.db, Collections.conversations, convoId);
await setDoc(
docRef,
{
membersInLiveRoom: arrayUnion(userJoiningId),
lastActivityDate: serverTimestamp(),
lastUpdatedBy: userJoiningId,
},
{ merge: true }
);
}
async leaveLiveConversation(convoId: string, userJoiningId: string) {
// todo: make sure that user is part of the convo or valid in it
const docRef = doc(this.db, Collections.conversations, convoId);
await setDoc(
docRef,
{
membersInLiveRoom: arrayRemove(userJoiningId),
lastActivityDate: serverTimestamp(),
lastUpdatedBy: userJoiningId,
},
{ merge: true }
);
}
}