Stop relying on the NotificationCenter for removing delivered push notifications:

- this will improve the architecture but more importantly will remove some very flakey unit tests
This commit is contained in:
Stefan Ceriu
2024-04-12 17:46:37 +03:00
committed by Stefan Ceriu
parent 891315ef04
commit 4d513f9ed1
15 changed files with 113 additions and 147 deletions
@@ -43,5 +43,4 @@ struct InvitesScreenRoomDetails: Identifiable {
enum InvitesScreenViewAction {
case accept(InvitesScreenRoomDetails)
case decline(InvitesScreenRoomDetails)
case appeared
}
@@ -57,8 +57,6 @@ class InvitesScreenViewModel: InvitesScreenViewModelType, InvitesScreenViewModel
accept(invite: invite)
case .decline(let invite):
startDeclineFlow(invite: invite)
case .appeared:
notificationCenterProtocol.post(name: .invitesScreenAppeared, object: nil)
}
}
@@ -45,9 +45,6 @@ struct InvitesScreen: View {
noInvitesContent
}
}
.onAppear {
context.send(viewAction: .appeared)
}
}
private var noInvitesContent: some View {
@@ -60,7 +60,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
switch await clientProxy.joinRoom(state.roomID) {
case .success:
actionsSubject.send(.joined)
case .failure(let error):
case .failure:
state.bindings.alertInfo = .init(id: .joinFailed)
}
}
@@ -415,12 +415,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
private func sendReadReceiptIfNeeded(for lastVisibleItemID: TimelineItemIdentifier) async {
guard application.applicationState == .active else { return }
// Clear any notifications from notification center.
if lastVisibleItemID.timelineID == state.timelineViewState.timelineIDs.last {
notificationCenter.post(name: .roomMarkedAsRead, object: roomProxy.id)
}
await timelineController.sendReadReceipt(for: lastVisibleItemID)
}