diff --git a/nirvana-ios/Views/Convos/ConvoViewModel.swift b/nirvana-ios/Views/Convos/ConvoViewModel.swift index c8e3e9b..d50de7b 100644 --- a/nirvana-ios/Views/Convos/ConvoViewModel.swift +++ b/nirvana-ios/Views/Convos/ConvoViewModel.swift @@ -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) diff --git a/nirvana-ios/Views/InnerCircle/CircleGridView.swift b/nirvana-ios/Views/InnerCircle/CircleGridView.swift index 168e711..8e30123 100644 --- a/nirvana-ios/Views/InnerCircle/CircleGridView.swift +++ b/nirvana-ios/Views/InnerCircle/CircleGridView.swift @@ -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() {