diff --git a/Session/Calls/Call Management/SessionCall.swift b/Session/Calls/Call Management/SessionCall.swift index 1aef15a69..56a6d8140 100644 --- a/Session/Calls/Call Management/SessionCall.swift +++ b/Session/Calls/Call Management/SessionCall.swift @@ -113,12 +113,12 @@ public final class SessionCall: CurrentCallProtocol, WebRTCSessionDelegate { set { connectingDate = newValue ? Date() : nil } } - var hasConnected: Bool { + public var hasConnected: Bool { get { return connectedDate != nil } set { connectedDate = newValue ? Date() : nil } } - var hasEnded: Bool { + public var hasEnded: Bool { get { return endDate != nil } set { endDate = newValue ? Date() : nil } } diff --git a/Session/Meta/AppDelegate.swift b/Session/Meta/AppDelegate.swift index 79db24db8..aeaa99275 100644 --- a/Session/Meta/AppDelegate.swift +++ b/Session/Meta/AppDelegate.swift @@ -132,11 +132,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD // NOTE: Fix an edge case where user taps on the callkit notification // but answers the call on another device - stopPollers(shouldStopUserPoller: !self.hasIncomingCallWaiting()) + stopPollers(shouldStopUserPoller: !self.hasCallOngoing()) // 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) + if !self.hasCallOngoing() { + NotificationCenter.default.post(name: Database.suspendNotification, object: self) + } } } @@ -634,6 +636,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD return !call.hasStartedConnecting } + func hasCallOngoing() -> Bool { + guard let call = AppEnvironment.shared.callManager.currentCall else { return false } + + return !call.hasEnded + } + func handleAppActivatedWithOngoingCallIfNeeded() { guard let call: SessionCall = (AppEnvironment.shared.callManager.currentCall as? SessionCall), diff --git a/SessionMessagingKit/Calls/CurrentCallProtocol.swift b/SessionMessagingKit/Calls/CurrentCallProtocol.swift index 6968116db..8cdaf7ff7 100644 --- a/SessionMessagingKit/Calls/CurrentCallProtocol.swift +++ b/SessionMessagingKit/Calls/CurrentCallProtocol.swift @@ -9,6 +9,7 @@ public protocol CurrentCallProtocol { var callId: UUID { get } var webRTCSession: WebRTCSession { get } var hasStartedConnecting: Bool { get set } + var hasEnded: Bool { get set } func updateCallMessage(mode: EndCallMode) func didReceiveRemoteSDP(sdp: RTCSessionDescription)