This commit is contained in:
talksik
2022-01-01 21:21:59 -08:00
parent bb6f9661d8
commit 6ece864ba1
2 changed files with 8 additions and 5 deletions
@@ -190,7 +190,8 @@ class ConvoViewModel: NSObject, ObservableObject {
}
}
func joinConvo(convo: Convo) {
/* internal control to join a convo */
private func joinConvo(convo: Convo) {
// ensure that this user leaves all other channels
if self.isInCall() {
self.leaveConvo()
@@ -203,8 +204,7 @@ class ConvoViewModel: NSObject, ObservableObject {
// finally join channel
self.agoraKit?.joinChannel(byToken: convo.agoraToken, channelId: convo.id!, info: nil, uid: 0, joinSuccess: nil)
}
/**
Allow user to join an active convo
*/
@@ -263,8 +263,6 @@ class ConvoViewModel: NSObject, ObservableObject {
// anyone can leave at any time
func leaveConvo() {
agoraKit?.leaveChannel(nil)
let userId = AuthSessionStore.getCurrentUserId()
if userId == nil {
@@ -277,6 +275,8 @@ class ConvoViewModel: NSObject, ObservableObject {
return
}
agoraKit?.leaveChannel(nil)
self.firestoreService.updateUserStatus(userId: userId!, userStatus: .online) {[weak self] res in
print(res)
@@ -464,6 +464,9 @@ extension CircleGridView {
private func handleTap(gridItemIndex: Int, friendId: String) {
print("tap gesture activated")
// TODO: make it deselect a currently selected user if that's the case
// if friend and I are online, and I am not in a convo, start convo immediately with them
if self.authSessionStore.relevantUsersDict[friendId]?.userStatus == .online
&& self.authSessionStore.user?.userStatus == .online && !self.convoVM.isInCall() {