mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Improve UX when answering EL-Call through the notification (#2965)
This commit is contained in:
@@ -145,15 +145,17 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
|||||||
|
|
||||||
registerBackgroundAppRefresh()
|
registerBackgroundAppRefresh()
|
||||||
|
|
||||||
elementCallService.actions.sink { [weak self] action in
|
elementCallService.actions
|
||||||
switch action {
|
.receive(on: DispatchQueue.main)
|
||||||
case .answerCall(let roomID):
|
.sink { [weak self] action in
|
||||||
self?.handleAppRoute(.call(roomID: roomID))
|
switch action {
|
||||||
case .declineCall:
|
case .answerCall(let roomID):
|
||||||
break
|
self?.handleAppRoute(.call(roomID: roomID))
|
||||||
|
case .declineCall:
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
.store(in: &cancellables)
|
||||||
.store(in: &cancellables)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func start() {
|
func start() {
|
||||||
|
|||||||
@@ -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()
|
||||||
@@ -48,7 +50,7 @@ class ElementCallService: NSObject, ElementCallServiceProtocol, PKPushRegistryDe
|
|||||||
guard ongoingCallID == nil else {
|
guard ongoingCallID == nil else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let callID = UUID()
|
let callID = UUID()
|
||||||
ongoingCallID = callID
|
ongoingCallID = callID
|
||||||
|
|
||||||
@@ -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