|
|
|
@ -104,8 +104,6 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public func reportIncomingCall(_ call: SessionCall, callerName: String, completion: @escaping (Error?) -> Void) {
|
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
|
|
|
|
|
|
let provider = provider ?? Self.sharedProvider(useSystemCallLog: false)
|
|
|
|
|
// Construct a CXCallUpdate describing the incoming call, including the caller.
|
|
|
|
|
let update = CXCallUpdate()
|
|
|
|
@ -139,8 +137,10 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
|
WebRTCSession.current = nil
|
|
|
|
|
UserDefaults.sharedLokiProject?.set(false, forKey: "isCallOngoing")
|
|
|
|
|
if CurrentAppContext().isInBackground() {
|
|
|
|
|
// Suspend the database
|
|
|
|
|
NotificationCenter.default.post(name: Database.suspendNotification, object: self)
|
|
|
|
|
// Stop all jobs except for message sending and when completed suspend the database
|
|
|
|
|
JobRunner.stopAndClearPendingJobs(exceptForVariant: .messageSend) {
|
|
|
|
|
NotificationCenter.default.post(name: Database.suspendNotification, object: self)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -186,12 +186,6 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
|
// MARK: - UI
|
|
|
|
|
|
|
|
|
|
public func showCallUIForCall(caller: String, uuid: String, mode: CallMode, interactionId: Int64?) {
|
|
|
|
|
guard Thread.isMainThread else {
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
self.showCallUIForCall(caller: caller, uuid: uuid, mode: mode, interactionId: interactionId)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
guard let call: SessionCall = Storage.shared.read({ db in SessionCall(db, for: caller, uuid: uuid, mode: mode) }) else {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -204,20 +198,23 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guard CurrentAppContext().isMainAppAndActive else { return }
|
|
|
|
|
guard let presentingVC = CurrentAppContext().frontmostViewController() else {
|
|
|
|
|
preconditionFailure() // FIXME: Handle more gracefully
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let conversationVC: ConversationVC = presentingVC as? ConversationVC, conversationVC.viewModel.threadData.threadId == call.sessionId {
|
|
|
|
|
let callVC = CallVC(for: call)
|
|
|
|
|
callVC.conversationVC = conversationVC
|
|
|
|
|
conversationVC.inputAccessoryView?.isHidden = true
|
|
|
|
|
conversationVC.inputAccessoryView?.alpha = 0
|
|
|
|
|
presentingVC.present(callVC, animated: true, completion: nil)
|
|
|
|
|
}
|
|
|
|
|
else if !Preferences.isCallKitSupported {
|
|
|
|
|
let incomingCallBanner = IncomingCallBanner(for: call)
|
|
|
|
|
incomingCallBanner.show()
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
|
guard let presentingVC = CurrentAppContext().frontmostViewController() else {
|
|
|
|
|
preconditionFailure() // FIXME: Handle more gracefully
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if let conversationVC: ConversationVC = presentingVC as? ConversationVC, conversationVC.viewModel.threadData.threadId == call.sessionId {
|
|
|
|
|
let callVC = CallVC(for: call)
|
|
|
|
|
callVC.conversationVC = conversationVC
|
|
|
|
|
conversationVC.inputAccessoryView?.isHidden = true
|
|
|
|
|
conversationVC.inputAccessoryView?.alpha = 0
|
|
|
|
|
presentingVC.present(callVC, animated: true, completion: nil)
|
|
|
|
|
}
|
|
|
|
|
else if !Preferences.isCallKitSupported {
|
|
|
|
|
let incomingCallBanner = IncomingCallBanner(for: call)
|
|
|
|
|
incomingCallBanner.show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|