tweaks on the logic to suspend database when call is ended in background

pull/687/head
ryanzhao 2 years ago
parent 7c1d332763
commit 87c2bc3700

@ -329,12 +329,7 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate {
)
},
completion: { _, _ in
if CurrentAppContext().isInBackground() {
// 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)
}
}
SessionCallManager.suspendDatabaseIfCallEndedInBackground()
}
)
}

@ -140,6 +140,7 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
guard let call = currentCall else {
handleCallEnded()
Self.suspendDatabaseIfCallEndedInBackground()
return
}
@ -177,6 +178,15 @@ public final class SessionCallManager: NSObject, CallManagerProtocol {
callUpdate.supportsDTMF = false
}
public static func suspendDatabaseIfCallEndedInBackground() {
if CurrentAppContext().isInBackground() {
// 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)
}
}
}
// MARK: - UI
public func showCallUIForCall(caller: String, uuid: String, mode: CallMode, interactionId: Int64?) {

Loading…
Cancel
Save