diff --git a/Session/Calls/Call Management/SessionCallManager+CXProvider.swift b/Session/Calls/Call Management/SessionCallManager+CXProvider.swift index 7b3fe2d3a..e0512066e 100644 --- a/Session/Calls/Call Management/SessionCallManager+CXProvider.swift +++ b/Session/Calls/Call Management/SessionCallManager+CXProvider.swift @@ -21,7 +21,7 @@ extension SessionCallManager: CXProviderDelegate { if let _ = CurrentAppContext().frontmostViewController() as? CallVC { call.answerSessionCall() } else { - guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully + guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // FIXME: Handle more gracefully let callVC = CallVC(for: self.currentCall!) if let conversationVC = presentingVC as? ConversationVC { callVC.conversationVC = conversationVC diff --git a/Session/Calls/Call Management/SessionCallManager.swift b/Session/Calls/Call Management/SessionCallManager.swift index 548f9bf52..0bebe3a24 100644 --- a/Session/Calls/Call Management/SessionCallManager.swift +++ b/Session/Calls/Call Management/SessionCallManager.swift @@ -114,7 +114,7 @@ public final class SessionCallManager: NSObject { } else { call.updateCallMessage(mode: .local) } - self.currentCall?.webRTCSession.dropConnection() + call.webRTCSession.dropConnection() self.currentCall = nil WebRTCSession.current = nil } diff --git a/Session/Calls/Views & Modals/IncomingCallBanner.swift b/Session/Calls/Views & Modals/IncomingCallBanner.swift index a4854f648..c108ceca3 100644 --- a/Session/Calls/Views & Modals/IncomingCallBanner.swift +++ b/Session/Calls/Views & Modals/IncomingCallBanner.swift @@ -151,7 +151,7 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate { public func showCallVC(answer: Bool) { dismiss() - guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully + guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // FIXME: Handle more gracefully let callVC = CallVC(for: self.call) if let conversationVC = presentingVC as? ConversationVC { callVC.conversationVC = conversationVC diff --git a/Session/Calls/Views & Modals/MiniCallView.swift b/Session/Calls/Views & Modals/MiniCallView.swift index 4296c0f81..6c7d5a424 100644 --- a/Session/Calls/Views & Modals/MiniCallView.swift +++ b/Session/Calls/Views & Modals/MiniCallView.swift @@ -96,7 +96,7 @@ final class MiniCallView: UIView, RTCVideoViewDelegate { // MARK: Interaction @objc private func handleTap(_ gestureRecognizer: UITapGestureRecognizer) { dismiss() - guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully + guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // FIXME: Handle more gracefully presentingVC.present(callVC, animated: true, completion: nil) } diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index 9581817eb..d2cd2687e 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -44,11 +44,6 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc present(callVC, animated: true, completion: nil) } } - - internal func showCallVCIfNeeded() { - guard let incomingCallBanner = IncomingCallBanner.current else { return } - incomingCallBanner.showCallVC(answer: false) - } // MARK: Blocking @objc func unblock() { diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index 690075fa0..49e986b0b 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -263,7 +263,6 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat didFinishInitialLayout = true markAllAsRead() self.becomeFirstResponder() - showCallVCIfNeeded() } override func viewWillDisappear(_ animated: Bool) { diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index e9d1d3529..94eaecf6b 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -9,8 +9,9 @@ extension AppDelegate { // MARK: Call handling @objc func handleAppActivatedWithOngoingCallIfNeeded() { guard let call = AppEnvironment.shared.callManager.currentCall else { return } + guard MiniCallView.current == nil else { return } if let callVC = CurrentAppContext().frontmostViewController() as? CallVC, callVC.call == call { return } - guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully + guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // FIXME: Handle more gracefully let callVC = CallVC(for: call) if let conversationVC = presentingVC as? ConversationVC, let contactThread = conversationVC.thread as? TSContactThread, contactThread.contactSessionID() == call.sessionID { callVC.conversationVC = conversationVC @@ -33,7 +34,7 @@ extension AppDelegate { SNLog("[Calls] Failed to report incoming call to CallKit due to error: \(error)") } else { if CurrentAppContext().isMainAppAndActive { - guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully + guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // FIXME: Handle more gracefully if let conversationVC = presentingVC as? ConversationVC, let contactThread = conversationVC.thread as? TSContactThread, contactThread.contactSessionID() == call.sessionID { let callVC = CallVC(for: call) callVC.conversationVC = conversationVC