Skip to content

Commit

Permalink
Move notifyOtherParticipants to the ElementCallConfiguration.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Nov 27, 2024
1 parent 7c1cdaf commit 833fa7d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 19 deletions.
1 change: 0 additions & 1 deletion ElementX/Sources/Application/AppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,6 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
let callScreenCoordinator = CallScreenCoordinator(parameters: .init(elementCallService: elementCallService,
configuration: configuration,
allowPictureInPicture: false,
notifyOtherParticipants: false,
appHooks: appHooks))

callScreenCoordinator.actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
// MARK: Calls

private func presentCallScreen(genericCallLink url: URL) {
presentCallScreen(configuration: .init(genericCallLink: url), notifyOtherParticipants: false)
presentCallScreen(configuration: .init(genericCallLink: url))
}

private func presentCallScreen(roomID: String, notifyOtherParticipants: Bool) async {
Expand All @@ -673,12 +673,12 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
clientID: InfoPlistReader.main.bundleIdentifier,
elementCallBaseURL: appSettings.elementCallBaseURL,
elementCallBaseURLOverride: appSettings.elementCallBaseURLOverride,
colorScheme: colorScheme),
notifyOtherParticipants: notifyOtherParticipants)
colorScheme: colorScheme,
notifyOtherParticipants: notifyOtherParticipants))
}

private var callScreenPictureInPictureController: AVPictureInPictureController?
private func presentCallScreen(configuration: ElementCallConfiguration, notifyOtherParticipants: Bool) {
private func presentCallScreen(configuration: ElementCallConfiguration) {
guard elementCallService.ongoingCallRoomIDPublisher.value != configuration.callRoomID else {
MXLog.info("Returning to existing call.")
callScreenPictureInPictureController?.stopPictureInPicture()
Expand All @@ -688,7 +688,6 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
let callScreenCoordinator = CallScreenCoordinator(parameters: .init(elementCallService: elementCallService,
configuration: configuration,
allowPictureInPicture: true,
notifyOtherParticipants: notifyOtherParticipants,
appHooks: appHooks))

callScreenCoordinator.actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ struct CallScreenCoordinatorParameters {
let elementCallService: ElementCallServiceProtocol
let configuration: ElementCallConfiguration
let allowPictureInPicture: Bool
let notifyOtherParticipants: Bool
let appHooks: AppHooks
}

Expand Down Expand Up @@ -44,7 +43,6 @@ final class CallScreenCoordinator: CoordinatorProtocol {
viewModel = CallScreenViewModel(elementCallService: parameters.elementCallService,
configuration: parameters.configuration,
allowPictureInPicture: parameters.allowPictureInPicture,
notifyOtherParticipants: parameters.notifyOtherParticipants,
appHooks: parameters.appHooks)
}

Expand Down
9 changes: 4 additions & 5 deletions ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
init(elementCallService: ElementCallServiceProtocol,
configuration: ElementCallConfiguration,
allowPictureInPicture: Bool,
notifyOtherParticipants: Bool,
appHooks: AppHooks) {
self.elementCallService = elementCallService
self.configuration = configuration
Expand All @@ -42,7 +41,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
switch configuration.kind {
case .genericCallLink(let url):
widgetDriver = GenericCallLinkWidgetDriver(url: url)
case .roomCall(let roomProxy, let clientProxy, _, _, _, _):
case .roomCall(let roomProxy, let clientProxy, _, _, _, _, _):
guard let deviceID = clientProxy.deviceID else { fatalError("Missing device ID for the call.") }
widgetDriver = roomProxy.elementCallWidgetDriver(deviceID: deviceID)
}
Expand Down Expand Up @@ -102,7 +101,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
}
.store(in: &cancellables)

setupCall(notifyOtherParticipants: notifyOtherParticipants)
setupCall()
}

override func process(viewAction: CallScreenViewAction) {
Expand Down Expand Up @@ -131,13 +130,13 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol

// MARK: - Private

private func setupCall(notifyOtherParticipants: Bool) {
private func setupCall() {
switch configuration.kind {
case .genericCallLink(let url):
state.url = url
// We need widget messaging to work before enabling CallKit, otherwise mute, hangup etc do nothing.

case .roomCall(let roomProxy, let clientProxy, let clientID, let elementCallBaseURL, let elementCallBaseURLOverride, let colorScheme):
case .roomCall(let roomProxy, let clientProxy, let clientID, let elementCallBaseURL, let elementCallBaseURLOverride, let colorScheme, let notifyOtherParticipants):
Task { [weak self] in
guard let self else { return }

Expand Down
4 changes: 2 additions & 2 deletions ElementX/Sources/Screens/CallScreen/View/CallScreen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ struct CallScreen_Previews: PreviewProvider {
clientID: "io.element.elementx",
elementCallBaseURL: "https://call.element.io",
elementCallBaseURLOverride: nil,
colorScheme: .light),
colorScheme: .light,
notifyOtherParticipants: false),
allowPictureInPicture: false,
notifyOtherParticipants: false,
appHooks: AppHooks())
}()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ struct ElementCallConfiguration {
clientID: String,
elementCallBaseURL: URL,
elementCallBaseURLOverride: URL?,
colorScheme: ColorScheme)
colorScheme: ColorScheme,
notifyOtherParticipants: Bool)
}

/// The type of call being configured i.e. whether it's an external URL or an internal room call.
Expand Down Expand Up @@ -58,21 +59,23 @@ struct ElementCallConfiguration {
clientID: String,
elementCallBaseURL: URL,
elementCallBaseURLOverride: URL?,
colorScheme: ColorScheme) {
colorScheme: ColorScheme,
notifyOtherParticipants: Bool) {
kind = .roomCall(roomProxy: roomProxy,
clientProxy: clientProxy,
clientID: clientID,
elementCallBaseURL: elementCallBaseURL,
elementCallBaseURLOverride: elementCallBaseURLOverride,
colorScheme: colorScheme)
colorScheme: colorScheme,
notifyOtherParticipants: notifyOtherParticipants)
}

/// A string representing the call being configured.
var callRoomID: String {
switch kind {
case .genericCallLink(let url):
url.absoluteString
case .roomCall(let roomProxy, _, _, _, _, _):
case .roomCall(let roomProxy, _, _, _, _, _, _):
roomProxy.id
}
}
Expand Down

0 comments on commit 833fa7d

Please sign in to comment.