From 6b3fcb08277bed59f52d47cc6dff5a28c6ecd9f9 Mon Sep 17 00:00:00 2001 From: talksik Date: Sat, 1 Jan 2022 18:11:34 -0800 Subject: [PATCH] working third person can now join the channel --- nirvana-ios/Views/Convos/ConvoViewModel.swift | 10 +++------- nirvana-ios/Views/Convos/ConvosView.swift | 2 +- .../Views/InnerCircle/CircleGridView.swift | 16 +++++++++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/nirvana-ios/Views/Convos/ConvoViewModel.swift b/nirvana-ios/Views/Convos/ConvoViewModel.swift index 377eb11..049ec19 100644 --- a/nirvana-ios/Views/Convos/ConvoViewModel.swift +++ b/nirvana-ios/Views/Convos/ConvoViewModel.swift @@ -200,17 +200,13 @@ class ConvoViewModel: NSObject, ObservableObject { /** Allow user to join an active convo */ - func joinConvo() { + func joinConvo(convoId: String) { // ensure the convo is active and includes 2 people in it currently...shouldn't be shown if not anyway - // ensure that this user leaves all other channels - if self.isInCall() { - print("can't join another call, already in one") - return - } + // ensure that this user leaves all other channels let convo = self.relevantConvos.first {convo in - convo.id == self.selectedConvoId + convo.id == convoId } if convo == nil { diff --git a/nirvana-ios/Views/Convos/ConvosView.swift b/nirvana-ios/Views/Convos/ConvosView.swift index d5dff04..2edb1b8 100644 --- a/nirvana-ios/Views/Convos/ConvosView.swift +++ b/nirvana-ios/Views/Convos/ConvosView.swift @@ -52,7 +52,7 @@ struct ConvosView: View { // if not in a call already if !self.vm.isInCall() { self.vm.selectedConvoId = self.vm.relevantConvos[index].id! - self.vm.joinConvo() + self.vm.joinConvo(convoId: currConvo.id!) return } diff --git a/nirvana-ios/Views/InnerCircle/CircleGridView.swift b/nirvana-ios/Views/InnerCircle/CircleGridView.swift index b2172dc..7832e93 100644 --- a/nirvana-ios/Views/InnerCircle/CircleGridView.swift +++ b/nirvana-ios/Views/InnerCircle/CircleGridView.swift @@ -115,13 +115,19 @@ struct CircleGridView: View { .onTapGesture { // if not in a call already if !self.convoVM.isInCall() { - self.convoVM.selectedConvoId = self.convoVM.relevantConvos[value].id! - self.convoVM.joinConvo() + print("joining convo now") - // if had selected an individual, don't want them in here anymore - self.selectedFriendIndex = nil + if let convoId = currConvo.id { + self.convoVM.selectedConvoId = convoId + self.convoVM.joinConvo(convoId: convoId) + + // if had selected an individual, don't want them selected here anymore + self.selectedFriendIndex = nil + } + else { + print("no convo id to join") + } - return } } .animation(