minor refactor on answering call logic

pull/560/head
ryanzhao 4 years ago
parent 02d0499618
commit 925bc8538c

@ -23,13 +23,14 @@ extension SessionCallManager: CXProviderDelegate {
} else { } else {
guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully
let callVC = CallVC(for: self.currentCall!) let callVC = CallVC(for: self.currentCall!)
callVC.shouldAnswer = true
if let conversationVC = presentingVC as? ConversationVC { if let conversationVC = presentingVC as? ConversationVC {
callVC.conversationVC = conversationVC callVC.conversationVC = conversationVC
conversationVC.inputAccessoryView?.isHidden = true conversationVC.inputAccessoryView?.isHidden = true
conversationVC.inputAccessoryView?.alpha = 0 conversationVC.inputAccessoryView?.alpha = 0
} }
presentingVC.present(callVC, animated: true, completion: nil) presentingVC.present(callVC, animated: true) {
call.answerSessionCall()
}
} }
action.fulfill() action.fulfill()
} else { } else {

@ -6,7 +6,6 @@ import UIKit
final class CallVC : UIViewController, VideoPreviewDelegate { final class CallVC : UIViewController, VideoPreviewDelegate {
let call: SessionCall let call: SessionCall
var shouldAnswer = false
var shouldRestartCamera = true var shouldRestartCamera = true
weak var conversationVC: ConversationVC? = nil weak var conversationVC: ConversationVC? = nil
@ -218,7 +217,6 @@ final class CallVC : UIViewController, VideoPreviewDelegate {
} }
} }
} }
if shouldAnswer { answerCall() }
} }
func setUpViewHierarchy() { func setUpViewHierarchy() {

@ -153,13 +153,14 @@ final class IncomingCallBanner: UIView, UIGestureRecognizerDelegate {
dismiss() dismiss()
guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully guard let presentingVC = CurrentAppContext().frontmostViewController() else { preconditionFailure() } // TODO: Handle more gracefully
let callVC = CallVC(for: self.call) let callVC = CallVC(for: self.call)
callVC.shouldAnswer = answer
if let conversationVC = presentingVC as? ConversationVC { if let conversationVC = presentingVC as? ConversationVC {
callVC.conversationVC = conversationVC callVC.conversationVC = conversationVC
conversationVC.inputAccessoryView?.isHidden = true conversationVC.inputAccessoryView?.isHidden = true
conversationVC.inputAccessoryView?.alpha = 0 conversationVC.inputAccessoryView?.alpha = 0
} }
presentingVC.present(callVC, animated: true, completion: nil) presentingVC.present(callVC, animated: true) {
if answer { self.call.answerSessionCall() }
}
} }
public func show() { public func show() {

Loading…
Cancel
Save