mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 10:33:45 +00:00
Fixes #3137 - Delay starting ElementCall until a sync response comes in (or a 5 second timeout)
- this will ensure that the room state is up to date before sending any call related events
This commit is contained in:
committed by
Stefan Ceriu
parent
0b984cc3eb
commit
0ad8f3cae8
@@ -31,6 +31,8 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
|||||||
actionsSubject.eraseToAnyPublisher()
|
actionsSubject.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var syncUpdateCancellable: AnyCancellable?
|
||||||
|
|
||||||
/// Designated initialiser
|
/// Designated initialiser
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
/// - elementCallService: service responsible for setting up CallKit
|
/// - elementCallService: service responsible for setting up CallKit
|
||||||
@@ -113,7 +115,15 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
|||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
Task {
|
// Wait for room states to be up to date before starting the call and notifying others
|
||||||
|
syncUpdateCancellable = clientProxy.actionsPublisher
|
||||||
|
.filter(\.isSyncUpdate)
|
||||||
|
.timeout(.seconds(5), scheduler: DispatchQueue.main)
|
||||||
|
.first() // Timeout will make the publisher complete, use first to handle both branches in the same place
|
||||||
|
.sink(receiveCompletion: { [weak self] _ in
|
||||||
|
Task { [weak self] in
|
||||||
|
guard let self else { return }
|
||||||
|
|
||||||
let baseURL = if let elementCallBaseURLOverride {
|
let baseURL = if let elementCallBaseURLOverride {
|
||||||
elementCallBaseURLOverride
|
elementCallBaseURLOverride
|
||||||
} else if case .success(let wellKnown) = await clientProxy.getElementWellKnown(), let wellKnownCall = wellKnown?.call {
|
} else if case .success(let wellKnown) = await clientProxy.getElementWellKnown(), let wellKnownCall = wellKnown?.call {
|
||||||
@@ -136,8 +146,11 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
|
|||||||
|
|
||||||
await elementCallService.setupCallSession(roomID: roomProxy.id, roomDisplayName: roomProxy.roomTitle)
|
await elementCallService.setupCallSession(roomID: roomProxy.id, roomDisplayName: roomProxy.roomTitle)
|
||||||
|
|
||||||
let _ = await roomProxy.sendCallNotificationIfNeeeded()
|
_ = await roomProxy.sendCallNotificationIfNeeeded()
|
||||||
|
|
||||||
|
syncUpdateCancellable = nil
|
||||||
}
|
}
|
||||||
|
}, receiveValue: { _ in })
|
||||||
}
|
}
|
||||||
|
|
||||||
override func process(viewAction: CallScreenViewAction) {
|
override func process(viewAction: CallScreenViewAction) {
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ struct CallScreen: View {
|
|||||||
@ObservedObject var context: CallScreenViewModel.Context
|
@ObservedObject var context: CallScreenViewModel.Context
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
if context.viewState.url == nil {
|
||||||
|
ProgressView()
|
||||||
|
} else {
|
||||||
WebView(url: context.viewState.url, viewModelContext: context)
|
WebView(url: context.viewState.url, viewModelContext: context)
|
||||||
// This URL is stable, forces view reloads if this representable is ever reused for another url
|
// This URL is stable, forces view reloads if this representable is ever reused for another url
|
||||||
.id(context.viewState.url)
|
.id(context.viewState.url)
|
||||||
@@ -30,6 +33,7 @@ struct CallScreen: View {
|
|||||||
.alert(item: $context.alertInfo)
|
.alert(item: $context.alertInfo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private struct WebView: UIViewRepresentable {
|
private struct WebView: UIViewRepresentable {
|
||||||
let url: URL?
|
let url: URL?
|
||||||
|
|||||||
Reference in New Issue
Block a user