|
|
@ -104,8 +104,6 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public func reportIncomingCall(_ call: SessionCall, callerName: String, completion: @escaping (Error?) -> Void) {
|
|
|
|
public func reportIncomingCall(_ call: SessionCall, callerName: String, completion: @escaping (Error?) -> Void) {
|
|
|
|
AssertIsOnMainThread()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let provider = provider ?? Self.sharedProvider(useSystemCallLog: false)
|
|
|
|
let provider = provider ?? Self.sharedProvider(useSystemCallLog: false)
|
|
|
|
// Construct a CXCallUpdate describing the incoming call, including the caller.
|
|
|
|
// Construct a CXCallUpdate describing the incoming call, including the caller.
|
|
|
|
let update = CXCallUpdate()
|
|
|
|
let update = CXCallUpdate()
|
|
|
@ -139,10 +137,12 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
WebRTCSession.current = nil
|
|
|
|
WebRTCSession.current = nil
|
|
|
|
UserDefaults.sharedLokiProject?.set(false, forKey: "isCallOngoing")
|
|
|
|
UserDefaults.sharedLokiProject?.set(false, forKey: "isCallOngoing")
|
|
|
|
if CurrentAppContext().isInBackground() {
|
|
|
|
if CurrentAppContext().isInBackground() {
|
|
|
|
// Suspend the database
|
|
|
|
// 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)
|
|
|
|
NotificationCenter.default.post(name: Database.suspendNotification, object: self)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
guard let call = currentCall else {
|
|
|
|
guard let call = currentCall else {
|
|
|
|
handleCallEnded()
|
|
|
|
handleCallEnded()
|
|
|
@ -186,12 +186,6 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
// MARK: - UI
|
|
|
|
// MARK: - UI
|
|
|
|
|
|
|
|
|
|
|
|
public func showCallUIForCall(caller: String, uuid: String, mode: CallMode, interactionId: Int64?) {
|
|
|
|
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 {
|
|
|
|
guard let call: SessionCall = Storage.shared.read({ db in SessionCall(db, for: caller, uuid: uuid, mode: mode) }) else {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -204,6 +198,8 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
guard CurrentAppContext().isMainAppAndActive else { return }
|
|
|
|
guard CurrentAppContext().isMainAppAndActive else { return }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DispatchQueue.main.async {
|
|
|
|
guard let presentingVC = CurrentAppContext().frontmostViewController() else {
|
|
|
|
guard let presentingVC = CurrentAppContext().frontmostViewController() else {
|
|
|
|
preconditionFailure() // FIXME: Handle more gracefully
|
|
|
|
preconditionFailure() // FIXME: Handle more gracefully
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -221,6 +217,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public func handleAnswerMessage(_ message: CallMessage) {
|
|
|
|
public func handleAnswerMessage(_ message: CallMessage) {
|
|
|
|
guard Thread.isMainThread else {
|
|
|
|
guard Thread.isMainThread else {
|
|
|
|