mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Final changes for Room Moderation (#2576)
* Add confirmation that the user would like to discard unsaved changes. * Update string on permissions screen. * Fix UI tests and update snapshots. * Fix integration tests. * Run periphery for Moderation feature.
This commit is contained in:
@@ -89,6 +89,8 @@ struct RoomChangeRolesScreenViewStateBindings {
|
||||
enum RoomChangeRolesScreenAlertType {
|
||||
/// A warning that a particular promotion can't be undone.
|
||||
case promotionWarning
|
||||
/// A confirmation that the user would like to discard any unsaved changes.
|
||||
case discardChanges
|
||||
/// The generic error message.
|
||||
case error
|
||||
}
|
||||
@@ -100,4 +102,6 @@ enum RoomChangeRolesScreenViewAction {
|
||||
case demoteMember(RoomMemberDetails)
|
||||
/// Save all the changes that the user has made.
|
||||
case save
|
||||
/// Discard any changes and hide the screen.
|
||||
case cancel
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ class RoomChangeRolesScreenViewModel: RoomChangeRolesScreenViewModelType, RoomCh
|
||||
} else {
|
||||
Task { await save() }
|
||||
}
|
||||
case .cancel:
|
||||
confirmDiscardChanges()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,6 +150,14 @@ class RoomChangeRolesScreenViewModel: RoomChangeRolesScreenViewModelType, RoomCh
|
||||
}
|
||||
}
|
||||
|
||||
private func confirmDiscardChanges() {
|
||||
state.bindings.alertInfo = AlertInfo(id: .discardChanges,
|
||||
title: L10n.screenRoomChangeRoleUnsavedChangesTitle,
|
||||
message: L10n.screenRoomChangeRoleUnsavedChangesDescription,
|
||||
primaryButton: .init(title: L10n.actionSave) { Task { await self.save() } },
|
||||
secondaryButton: .init(title: L10n.actionDiscard, role: .cancel) { self.actionsSubject.send(.complete) })
|
||||
}
|
||||
|
||||
// MARK: Loading indicator
|
||||
|
||||
private static let indicatorID = "SavingRoomRoles"
|
||||
|
||||
@@ -61,15 +61,6 @@ struct RoomChangeRolesScreen: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var noResultsContent: some View {
|
||||
Text(L10n.commonNoResults)
|
||||
.font(.compound.bodyLG)
|
||||
.foregroundColor(.compound.textSecondary)
|
||||
.frame(maxWidth: .infinity)
|
||||
.listRowBackground(Color.clear)
|
||||
.accessibilityIdentifier(A11yIdentifiers.startChatScreen.searchNoResults)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
private var membersSection: some View {
|
||||
if !context.viewState.visibleMembers.isEmpty {
|
||||
@@ -123,6 +114,14 @@ struct RoomChangeRolesScreen: View {
|
||||
}
|
||||
.disabled(!context.viewState.hasChanges)
|
||||
}
|
||||
|
||||
if context.viewState.hasChanges {
|
||||
ToolbarItem(placement: .cancellationAction) {
|
||||
Button(L10n.actionCancel) {
|
||||
context.send(viewAction: .cancel)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user