mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Improve UX when answering EL-Call through the notification (#2965)
This commit is contained in:
@@ -145,7 +145,9 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
|
|
||||||
registerBackgroundAppRefresh()
|
registerBackgroundAppRefresh()
|
||||||
|
|
||||||
elementCallService.actions.sink { [weak self] action in
|
elementCallService.actions
|
||||||
|
.receive(on: DispatchQueue.main)
|
||||||
|
.sink { [weak self] action in
|
||||||
switch action {
|
switch action {
|
||||||
case .answerCall(let roomID):
|
case .answerCall(let roomID):
|
||||||
self?.handleAppRoute(.call(roomID: roomID))
|
self?.handleAppRoute(.call(roomID: roomID))
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
|||||||
|
|
||||||
private var incomingCallRoomID: String?
|
private var incomingCallRoomID: String?
|
||||||
|
|
||||||
|
private var endUnansweredCallTask: Task<Void, Never>?
|
||||||
|
|
||||||
private let actionsSubject: PassthroughSubject<ElementCallServiceAction, Never> = .init()
|
private let actionsSubject: PassthroughSubject<ElementCallServiceAction, Never> = .init()
|
||||||
var actions: AnyPublisher<ElementCallServiceAction, Never> {
|
var actions: AnyPublisher<ElementCallServiceAction, Never> {
|
||||||
actionsSubject.eraseToAnyPublisher()
|
actionsSubject.eraseToAnyPublisher()
|
||||||
@@ -103,6 +105,8 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
|||||||
let configuration = CXProviderConfiguration()
|
let configuration = CXProviderConfiguration()
|
||||||
configuration.supportsVideo = true
|
configuration.supportsVideo = true
|
||||||
configuration.includesCallsInRecents = true
|
configuration.includesCallsInRecents = true
|
||||||
|
// Provide image icon if available
|
||||||
|
configuration.iconTemplateImageData = nil
|
||||||
|
|
||||||
// https://stackoverflow.com/a/46077628/730924
|
// https://stackoverflow.com/a/46077628/730924
|
||||||
configuration.supportedHandleTypes = [.generic]
|
configuration.supportedHandleTypes = [.generic]
|
||||||
@@ -125,8 +129,12 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
|||||||
completion()
|
completion()
|
||||||
}
|
}
|
||||||
|
|
||||||
Task { [weak self, callProvider, callID] in
|
endUnansweredCallTask = Task { [weak self, callProvider, callID] in
|
||||||
try? await Task.sleep(for: .seconds(15))
|
try? await Task.sleep(for: .seconds(15))
|
||||||
|
guard !Task.isCancelled else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if let ongoingCallID = self?.ongoingCallID, ongoingCallID == callID {
|
if let ongoingCallID = self?.ongoingCallID, ongoingCallID == callID {
|
||||||
callProvider.reportCall(with: callID, endedAt: .now, reason: .unanswered)
|
callProvider.reportCall(with: callID, endedAt: .now, reason: .unanswered)
|
||||||
}
|
}
|
||||||
@@ -146,6 +154,7 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
|||||||
actionsSubject.send(.answerCall(roomID: incomingCallRoomID))
|
actionsSubject.send(.answerCall(roomID: incomingCallRoomID))
|
||||||
}
|
}
|
||||||
self.incomingCallRoomID = nil
|
self.incomingCallRoomID = nil
|
||||||
|
endUnansweredCallTask?.cancel()
|
||||||
} else {
|
} else {
|
||||||
MXLog.error("Failed answering incoming call, missing room ID")
|
MXLog.error("Failed answering incoming call, missing room ID")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user