fix call threading issues

pull/687/head
Ryan Zhao 2 years ago
parent 80894bc198
commit 31605672e2

@ -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,10 +137,12 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
WebRTCSession.current = nil
UserDefaults.sharedLokiProject?.set(false, forKey: "isCallOngoing")
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)
}
}
}
guard let call = currentCall else {
handleCallEnded()
@ -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,6 +198,8 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
}
guard CurrentAppContext().isMainAppAndActive else { return }
DispatchQueue.main.async {
guard let presentingVC = CurrentAppContext().frontmostViewController() else {
preconditionFailure() // FIXME: Handle more gracefully
}
@ -221,6 +217,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
}
}
}
}
public func handleAnswerMessage(_ message: CallMessage) {
guard Thread.isMainThread else {

@ -28,7 +28,7 @@ public final class PushNotificationAPI : NSObject {
}
// MARK: - Settings
public static let server = "https://live.apns.getsession.org"
public static let server = "https://dev.apns.getsession.org"
public static let serverPublicKey = "642a6585919742e5a2d4dc51244964fbcd8bcab2b75612407de58b810740d049"
private static let maxRetryCount: UInt = 4

Loading…
Cancel
Save