feat: decline and block screen

fix

improvement

fix conflict

fix tests

tests
This commit is contained in:
Mauro Romito
2025-04-03 17:36:34 +02:00
committed by Mauro
parent 2ee5c1b403
commit d92fecdc7e
32 changed files with 597 additions and 13 deletions
@@ -18,6 +18,7 @@ enum HomeScreenCoordinatorAction {
case presentRoom(roomIdentifier: String)
case presentRoomDetails(roomIdentifier: String)
case presentReportRoom(roomIdentifier: String)
case presentDeclineAndBlock(userID: String, roomID: String)
case roomLeft(roomIdentifier: String)
case presentSettingsScreen
case presentFeedbackScreen
@@ -81,6 +82,8 @@ final class HomeScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.logoutWithoutConfirmation)
case .logout:
actionsSubject.send(.logout)
case .presentDeclineAndBlock(let userID, let roomID):
actionsSubject.send(.presentDeclineAndBlock(userID: userID, roomID: roomID))
}
}
.store(in: &cancellables)
@@ -13,6 +13,7 @@ enum HomeScreenViewModelAction: Equatable {
case presentRoom(roomIdentifier: String)
case presentRoomDetails(roomIdentifier: String)
case presentReportRoom(roomIdentifier: String)
case presentDeclineAndBlock(userID: String, roomID: String)
case roomLeft(roomIdentifier: String)
case presentSecureBackupSettings
case presentRecoveryKeyScreen
@@ -426,11 +426,24 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
let title = room.isDirect ? L10n.screenInvitesDeclineDirectChatTitle : L10n.screenInvitesDeclineChatTitle
let message = room.isDirect ? L10n.screenInvitesDeclineDirectChatMessage(roomPlaceholder) : L10n.screenInvitesDeclineChatMessage(roomPlaceholder)
state.bindings.alertInfo = .init(id: UUID(),
title: title,
message: message,
primaryButton: .init(title: L10n.actionDecline, role: .destructive) { Task { await self.declineInvite(roomID: room.id) } },
secondaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil))
if appSettings.reportInviteEnabled, let userID = room.inviter?.id {
state.bindings.alertInfo = .init(id: UUID(),
title: title,
message: message,
primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil),
secondaryButton: .init(title: L10n.actionDeclineAndBlock, role: .destructive) { [weak self] in self?.declineAndBlockInvite(userID: userID, roomID: roomID) },
verticalButtons: [.init(title: L10n.actionDecline) { [weak self] in Task { await self?.declineInvite(roomID: room.id) } }])
} else {
state.bindings.alertInfo = .init(id: UUID(),
title: title,
message: message,
primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil),
secondaryButton: .init(title: L10n.actionDecline, role: .destructive) { [weak self] in Task { await self?.declineInvite(roomID: room.id) } })
}
}
private func declineAndBlockInvite(userID: String, roomID: String) {
actionsSubject.send(.presentDeclineAndBlock(userID: userID, roomID: roomID))
}
private func declineInvite(roomID: String) async {