mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Report room and decline & block screens tweaks (#4044)
* report rom and decline and block screens tweaks - Use the copies: "Leave room" and "Report room" everywhere, also in DMs - Report reason in report room is now mandatory. - Report reason in decline and block is now mandatory if the report action is set to on. - Generic alert for failure of main API in both report room and decline and block has been added * report room and decline and block screen previews
This commit is contained in:
@@ -15,7 +15,10 @@ struct DeclineAndBlockScreenViewState: BindableState {
|
||||
var bindings = DeclineAndBlockScreenViewStateBindings()
|
||||
|
||||
var isDeclineDisabled: Bool {
|
||||
!bindings.shouldBlockUser && !bindings.shouldReport
|
||||
if bindings.shouldReport {
|
||||
return bindings.reportReason.isEmpty
|
||||
}
|
||||
return !bindings.shouldBlockUser && !bindings.shouldReport
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +26,15 @@ struct DeclineAndBlockScreenViewStateBindings {
|
||||
var shouldBlockUser = true
|
||||
var shouldReport = false
|
||||
var reportReason = ""
|
||||
|
||||
var alert: AlertInfo<DeclineAndBlockAlertType>?
|
||||
}
|
||||
|
||||
enum DeclineAndBlockScreenViewAction {
|
||||
case decline
|
||||
case dismiss
|
||||
}
|
||||
|
||||
enum DeclineAndBlockAlertType {
|
||||
case declineFailed
|
||||
}
|
||||
|
||||
+11
-3
@@ -50,7 +50,7 @@ class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, Declin
|
||||
guard case let .invited(roomProxy) = await clientProxy.roomForIdentifier(roomID) else {
|
||||
MXLog.error("DeclineAndBlockScreenViewModel: Unable to find an invited room for identifier \(roomID)")
|
||||
hideLoadingIndicator()
|
||||
showError()
|
||||
showTryAgainAlert { [weak self] in Task { await self?.decline() } }
|
||||
return
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, Declin
|
||||
case .success:
|
||||
var shouldShowFailure = false
|
||||
if state.bindings.shouldReport {
|
||||
shouldShowFailure = await clientProxy.reportRoomForIdentifier(roomID, reason: state.bindings.reportReason.isBlank ? nil : state.bindings.reportReason).isFailure
|
||||
shouldShowFailure = await clientProxy.reportRoomForIdentifier(roomID, reason: state.bindings.reportReason.isEmpty ? nil : state.bindings.reportReason).isFailure
|
||||
}
|
||||
|
||||
if state.bindings.shouldBlockUser {
|
||||
@@ -74,7 +74,7 @@ class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, Declin
|
||||
actionsSubject.send(.dismiss(hasDeclined: true))
|
||||
case .failure:
|
||||
hideLoadingIndicator()
|
||||
showError()
|
||||
showTryAgainAlert { [weak self] in Task { await self?.decline() } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,6 +97,14 @@ class DeclineAndBlockScreenViewModel: DeclineAndBlockScreenViewModelType, Declin
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
|
||||
}
|
||||
|
||||
private func showTryAgainAlert(retryAction: @escaping () -> Void) {
|
||||
state.bindings.alert = .init(id: .declineFailed,
|
||||
title: L10n.commonSomethingWentWrong,
|
||||
message: L10n.commonSomethingWentWrongMessage,
|
||||
primaryButton: .init(title: L10n.actionDismiss, role: .cancel, action: nil),
|
||||
secondaryButton: .init(title: L10n.actionTryAgain, action: retryAction))
|
||||
}
|
||||
|
||||
private func showSuccess() {
|
||||
userIndicatorController.submitIndicator(.init(title: L10n.commonSuccess, iconName: "checkmark"))
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ struct DeclineAndBlockScreen: View {
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar { toolbar }
|
||||
.animation(.elementDefault, value: context.shouldReport)
|
||||
.alert(item: $context.alert)
|
||||
}
|
||||
|
||||
private var blockUserSection: some View {
|
||||
|
||||
Reference in New Issue
Block a user