mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Knock Polishing part 4 (#3779)
* added decline and block and inviter redesign * improved testing * improved testing * code improvement * code improvement * improved the code
This commit is contained in:
@@ -66,6 +66,8 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
showCancelKnockConfirmationAlert()
|
||||
case .dismiss:
|
||||
actionsSubject.send(.dismiss)
|
||||
case .declineInviteAndBlock(let userID):
|
||||
showDeclineAndBlockConfirmationAlert(userID: userID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +304,27 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
secondaryButton: .init(title: L10n.screenJoinRoomCancelKnockAlertConfirmation, role: .destructive) { Task { await self.cancelKnock() } })
|
||||
}
|
||||
|
||||
private func declineInvite() async {
|
||||
private func showDeclineAndBlockConfirmationAlert(userID: String) {
|
||||
state.bindings.alertInfo = .init(id: .declineInviteAndBlock,
|
||||
title: L10n.screenJoinRoomDeclineAndBlockAlertTitle,
|
||||
message: L10n.screenJoinRoomDeclineAndBlockAlertMessage(userID),
|
||||
primaryButton: .init(title: L10n.actionCancel, role: .cancel, action: nil),
|
||||
secondaryButton: .init(title: L10n.screenJoinRoomDeclineAndBlockAlertConfirmation, role: .destructive) { Task { await self.declineAndBlock(userID: userID) } })
|
||||
}
|
||||
|
||||
private func declineAndBlock(userID: String) async {
|
||||
guard await declineInvite() else {
|
||||
return
|
||||
}
|
||||
// The decline alert and the view are already dismissed at this point so we can dispatch this separately as a best effort
|
||||
// but only if the decline invite was succesfull
|
||||
Task {
|
||||
await clientProxy.ignoreUser(userID)
|
||||
}
|
||||
}
|
||||
|
||||
@discardableResult
|
||||
private func declineInvite() async -> Bool {
|
||||
defer {
|
||||
userIndicatorController.retractIndicatorWithId(roomID)
|
||||
}
|
||||
@@ -311,16 +333,18 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo
|
||||
|
||||
guard case let .invited(roomProxy) = room else {
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
let result = await roomProxy.rejectInvitation()
|
||||
|
||||
if case .failure = result {
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
||||
} else {
|
||||
actionsSubject.send(.dismiss)
|
||||
return false
|
||||
}
|
||||
|
||||
actionsSubject.send(.dismiss)
|
||||
return true
|
||||
}
|
||||
|
||||
private func cancelKnock() async {
|
||||
|
||||
Reference in New Issue
Block a user