Skip to content

Commit 3de60bb

Browse files
committed
Stop sending call notifications
In an upcoming version of Element Call, the Element Call widget will assume responsibility for sending notification events when you start a call. So we no longer need to have the client application send them.
1 parent 5197e41 commit 3de60bb

File tree

7 files changed

+12
-36
lines changed

7 files changed

+12
-36
lines changed

ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
200200
case .userProfile(let userID):
201201
stateMachine.processEvent(.showUserProfileScreen(userID: userID), userInfo: .init(animated: animated))
202202
case .call(let roomID):
203-
Task { await presentCallScreen(roomID: roomID, notifyOtherParticipants: false) }
203+
Task { await presentCallScreen(roomID: roomID) }
204204
case .genericCallLink(let url):
205205
presentCallScreen(genericCallLink: url)
206206
case .settings, .chatBackupSettings:
@@ -683,8 +683,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
683683

684684
switch action {
685685
case .presentCallScreen(let roomProxy):
686-
// Here we assume that the app is running and the call state is already up to date
687-
presentCallScreen(roomProxy: roomProxy, notifyOtherParticipants: !roomProxy.infoPublisher.value.hasRoomCall)
686+
presentCallScreen(roomProxy: roomProxy)
688687
case .verifyUser(let userID):
689688
presentSessionVerificationScreen(flow: .userIntiator(userID: userID))
690689
case .finished:
@@ -765,23 +764,22 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
765764
presentCallScreen(configuration: .init(genericCallLink: url))
766765
}
767766

768-
private func presentCallScreen(roomID: String, notifyOtherParticipants: Bool) async {
767+
private func presentCallScreen(roomID: String) async {
769768
guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else {
770769
return
771770
}
772771

773-
presentCallScreen(roomProxy: roomProxy, notifyOtherParticipants: notifyOtherParticipants)
772+
presentCallScreen(roomProxy: roomProxy)
774773
}
775774

776-
private func presentCallScreen(roomProxy: JoinedRoomProxyProtocol, notifyOtherParticipants: Bool) {
775+
private func presentCallScreen(roomProxy: JoinedRoomProxyProtocol) {
777776
let colorScheme: ColorScheme = appMediator.windowManager.mainWindow.traitCollection.userInterfaceStyle == .light ? .light : .dark
778777
presentCallScreen(configuration: .init(roomProxy: roomProxy,
779778
clientProxy: userSession.clientProxy,
780779
clientID: InfoPlistReader.main.bundleIdentifier,
781780
elementCallBaseURL: appSettings.elementCallBaseURL,
782781
elementCallBaseURLOverride: appSettings.elementCallBaseURLOverride,
783-
colorScheme: colorScheme,
784-
notifyOtherParticipants: notifyOtherParticipants))
782+
colorScheme: colorScheme))
785783
}
786784

787785
private var callScreenPictureInPictureController: AVPictureInPictureController?
@@ -1006,7 +1004,7 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol {
10061004
navigationSplitCoordinator.setSheetCoordinator(nil)
10071005
stateMachine.processEvent(.selectRoom(roomID: roomID, via: [], entryPoint: .room))
10081006
case .startCall(let roomID):
1009-
Task { await self.presentCallScreen(roomID: roomID, notifyOtherParticipants: false) }
1007+
Task { await self.presentCallScreen(roomID: roomID) }
10101008
case .dismiss:
10111009
navigationSplitCoordinator.setSheetCoordinator(nil)
10121010
}

ElementX/Sources/Mocks/JoinedRoomProxyMock.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ extension JoinedRoomProxyMock {
127127
widgetDriver.startBaseURLClientIDColorSchemeRageshakeURLAnalyticsConfigurationReturnValue = .success(url)
128128

129129
elementCallWidgetDriverDeviceIDReturnValue = widgetDriver
130-
sendCallNotificationIfNeededReturnValue = .success(())
131130

132131
matrixToPermalinkReturnValue = .success(.homeDirectory)
133132
matrixToEventPermalinkReturnValue = .success(.homeDirectory)

ElementX/Sources/Screens/CallScreen/CallScreenViewModel.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
142142
state.url = url
143143
// We need widget messaging to work before enabling CallKit, otherwise mute, hangup etc do nothing.
144144

145-
case .roomCall(let roomProxy, _, let clientID, let elementCallBaseURL, let elementCallBaseURLOverride, let colorScheme, let notifyOtherParticipants):
145+
case .roomCall(let roomProxy, _, let clientID, let elementCallBaseURL, let elementCallBaseURLOverride, let colorScheme):
146146
Task { [weak self] in
147147
guard let self else { return }
148148

@@ -175,10 +175,6 @@ class CallScreenViewModel: CallScreenViewModelType, CallScreenViewModelProtocol
175175

176176
await elementCallService.setupCallSession(roomID: roomProxy.id,
177177
roomDisplayName: roomProxy.infoPublisher.value.displayName ?? roomProxy.id)
178-
179-
if notifyOtherParticipants {
180-
_ = await roomProxy.sendCallNotificationIfNeeded()
181-
}
182178
}
183179
}
184180
}

ElementX/Sources/Screens/CallScreen/View/CallScreen.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ struct CallScreen_Previews: PreviewProvider {
295295
clientProxy.deviceID = "call-device-id"
296296

297297
let roomProxy = JoinedRoomProxyMock()
298-
roomProxy.sendCallNotificationIfNeededReturnValue = .success(())
299298

300299
let widgetDriver = ElementCallWidgetDriverMock()
301300
widgetDriver.underlyingMessagePublisher = .init()
@@ -310,8 +309,7 @@ struct CallScreen_Previews: PreviewProvider {
310309
clientID: "io.element.elementx",
311310
elementCallBaseURL: "https://call.element.io",
312311
elementCallBaseURLOverride: nil,
313-
colorScheme: .light,
314-
notifyOtherParticipants: false),
312+
colorScheme: .light),
315313
allowPictureInPicture: false,
316314
appHooks: AppHooks(),
317315
appSettings: ServiceLocator.shared.settings,

ElementX/Sources/Services/ElementCall/ElementCallConfiguration.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ struct ElementCallConfiguration {
2121
clientID: String,
2222
elementCallBaseURL: URL,
2323
elementCallBaseURLOverride: URL?,
24-
colorScheme: ColorScheme,
25-
notifyOtherParticipants: Bool)
24+
colorScheme: ColorScheme)
2625
}
2726

2827
/// The type of call being configured i.e. whether it's an external URL or an internal room call.
@@ -59,15 +58,13 @@ struct ElementCallConfiguration {
5958
clientID: String,
6059
elementCallBaseURL: URL,
6160
elementCallBaseURLOverride: URL?,
62-
colorScheme: ColorScheme,
63-
notifyOtherParticipants: Bool) {
61+
colorScheme: ColorScheme) {
6462
kind = .roomCall(roomProxy: roomProxy,
6563
clientProxy: clientProxy,
6664
clientID: clientID,
6765
elementCallBaseURL: elementCallBaseURL,
6866
elementCallBaseURLOverride: elementCallBaseURLOverride,
69-
colorScheme: colorScheme,
70-
notifyOtherParticipants: notifyOtherParticipants)
67+
colorScheme: colorScheme)
7168
}
7269

7370
/// A string representing the call being configured.

ElementX/Sources/Services/Room/JoinedRoomProxy.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -706,16 +706,6 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
706706
ElementCallWidgetDriver(room: room, deviceID: deviceID)
707707
}
708708

709-
func sendCallNotificationIfNeeded() async -> Result<Void, RoomProxyError> {
710-
do {
711-
try await room.sendCallNotificationIfNeeded()
712-
return .success(())
713-
} catch {
714-
MXLog.error("Failed room call notification with error: \(error)")
715-
return .failure(.sdkError(error))
716-
}
717-
}
718-
719709
// MARK: - Permalinks
720710

721711
func matrixToPermalink() async -> Result<URL, RoomProxyError> {

ElementX/Sources/Services/Room/RoomProxyProtocol.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ protocol JoinedRoomProxyProtocol: RoomProxyProtocol {
173173
func canUserJoinCall(userID: String) async -> Result<Bool, RoomProxyError>
174174
func elementCallWidgetDriver(deviceID: String) -> ElementCallWidgetDriverProtocol
175175

176-
func sendCallNotificationIfNeeded() async -> Result<Void, RoomProxyError>
177-
178176
// MARK: - Permalinks
179177

180178
func matrixToPermalink() async -> Result<URL, RoomProxyError>

0 commit comments

Comments
 (0)