Final design for pending members when changing roles. (#2668)

* Final design for pending users when changing role.

* Remove room moderation feature flag.

* Fix tests.

* Run periphery.

* Update snapshots.
This commit is contained in:
Doug
2024-04-09 12:00:11 +01:00
committed by GitHub
parent c61135f88c
commit 0856891733
33 changed files with 58 additions and 126 deletions
@@ -52,7 +52,6 @@ final class AppSettings {
case roomListFiltersEnabled
case markAsUnreadEnabled
case markAsFavouriteEnabled
case roomModerationEnabled
case publicSearchEnabled
case qrCodeLoginEnabled
}
@@ -282,9 +281,6 @@ final class AppSettings {
// MARK: - Feature Flags
@UserPreference(key: UserDefaultsKeys.roomModerationEnabled, defaultValue: false, storageType: .userDefaults(store))
var roomModerationEnabled
@UserPreference(key: UserDefaultsKeys.publicSearchEnabled, defaultValue: false, storageType: .volatile)
var publicSearchEnabled
@@ -500,8 +500,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
userIndicatorController: userIndicatorController,
notificationSettings: userSession.clientProxy.notificationSettings,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: appSettings.permalinkBaseURL,
mentionBuilder: MentionBuilder()),
appSettings: appSettings)
mentionBuilder: MentionBuilder()))
let coordinator = RoomDetailsScreenCoordinator(parameters: params)
coordinator.actions.sink { [weak self] action in
guard let self else { return }
@@ -543,7 +542,6 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
let parameters = RoomMembersListScreenCoordinatorParameters(mediaProvider: userSession.mediaProvider,
roomProxy: roomProxy,
userIndicatorController: userIndicatorController,
appSettings: appSettings,
analytics: analytics)
let coordinator = RoomMembersListScreenCoordinator(parameters: parameters)
@@ -19,8 +19,6 @@ import MatrixRustSDK
import SwiftUI
struct RoomChangeRolesScreenRow: View {
@Environment(\.isEnabled) private var isEnabled
let member: RoomMemberDetails
let imageProvider: ImageProviderProtocol?
@@ -28,22 +26,13 @@ struct RoomChangeRolesScreenRow: View {
let action: () -> Void
var body: some View {
ListRow(label: .avatar(title: memberName,
ListRow(label: .avatar(title: member.name ?? member.id,
status: member.isInvited ? L10n.screenRoomMemberListPendingHeaderTitle : nil,
description: member.name == nil ? nil : member.id,
icon: avatar),
kind: .multiSelection(isSelected: isSelected, action: action))
}
var memberName: String {
let name = member.name ?? member.id
return if member.isInvited {
L10n.screenRoomChangeRoleInvitedMemberName(name)
} else {
name
}
}
var avatar: LoadableAvatarImage {
LoadableAvatarImage(url: member.avatarURL,
name: member.name,
@@ -25,7 +25,6 @@ struct RoomDetailsScreenCoordinatorParameters {
let userIndicatorController: UserIndicatorControllerProtocol
let notificationSettings: NotificationSettingsProxyProtocol
let attributedStringBuilder: AttributedStringBuilderProtocol
let appSettings: AppSettings
}
enum RoomDetailsScreenCoordinatorAction {
@@ -55,8 +54,7 @@ final class RoomDetailsScreenCoordinator: CoordinatorProtocol {
analyticsService: parameters.analyticsService,
userIndicatorController: parameters.userIndicatorController,
notificationSettingsProxy: parameters.notificationSettings,
attributedStringBuilder: parameters.attributedStringBuilder,
appSettings: parameters.appSettings)
attributedStringBuilder: parameters.attributedStringBuilder)
}
// MARK: - Public
@@ -27,7 +27,6 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
private let userIndicatorController: UserIndicatorControllerProtocol
private let notificationSettingsProxy: NotificationSettingsProxyProtocol
private let attributedStringBuilder: AttributedStringBuilderProtocol
private let appSettings: AppSettings
private var dmRecipient: RoomMemberProxyProtocol?
@@ -43,8 +42,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
analyticsService: AnalyticsService,
userIndicatorController: UserIndicatorControllerProtocol,
notificationSettingsProxy: NotificationSettingsProxyProtocol,
attributedStringBuilder: AttributedStringBuilderProtocol,
appSettings: AppSettings) {
attributedStringBuilder: AttributedStringBuilderProtocol) {
self.roomProxy = roomProxy
self.clientProxy = clientProxy
self.mediaProvider = mediaProvider
@@ -52,7 +50,6 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
self.userIndicatorController = userIndicatorController
self.notificationSettingsProxy = notificationSettingsProxy
self.attributedStringBuilder = attributedStringBuilder
self.appSettings = appSettings
let topic = attributedStringBuilder.fromPlain(roomProxy.topic)
@@ -181,11 +178,7 @@ class RoomDetailsScreenViewModel: RoomDetailsScreenViewModelType, RoomDetailsScr
state.canEditRoomName = await (try? roomProxy.canUser(userID: roomProxy.ownUserID, sendStateEvent: .roomName).get()) == true
state.canEditRoomTopic = await (try? roomProxy.canUser(userID: roomProxy.ownUserID, sendStateEvent: .roomTopic).get()) == true
state.canEditRoomAvatar = await (try? roomProxy.canUser(userID: roomProxy.ownUserID, sendStateEvent: .roomAvatar).get()) == true
if appSettings.roomModerationEnabled {
state.canEditRolesOrPermissions = await (try? roomProxy.suggestedRole(for: roomProxy.ownUserID).get()) == .administrator
}
state.canEditRolesOrPermissions = await (try? roomProxy.suggestedRole(for: roomProxy.ownUserID).get()) == .administrator
state.canInviteUsers = await (try? roomProxy.canUserInvite(userID: roomProxy.ownUserID).get()) == true
}
@@ -320,8 +320,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxy,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: .userDirectory,
mentionBuilder: MentionBuilder()),
appSettings: ServiceLocator.shared.settings)
mentionBuilder: MentionBuilder()))
}()
static let dmRoomViewModel = {
@@ -347,8 +346,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxy,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: .userDirectory,
mentionBuilder: MentionBuilder()),
appSettings: ServiceLocator.shared.settings)
mentionBuilder: MentionBuilder()))
}()
static let simpleRoomViewModel = {
@@ -373,8 +371,7 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
userIndicatorController: ServiceLocator.shared.userIndicatorController,
notificationSettingsProxy: notificationSettingsProxy,
attributedStringBuilder: AttributedStringBuilder(permalinkBaseURL: .userDirectory,
mentionBuilder: MentionBuilder()),
appSettings: ServiceLocator.shared.settings)
mentionBuilder: MentionBuilder()))
}()
static var previews: some View {
@@ -21,7 +21,6 @@ struct RoomMembersListScreenCoordinatorParameters {
let mediaProvider: MediaProviderProtocol
let roomProxy: RoomProxyProtocol
let userIndicatorController: UserIndicatorControllerProtocol
let appSettings: AppSettings
let analytics: AnalyticsService
}
@@ -44,7 +43,6 @@ final class RoomMembersListScreenCoordinator: CoordinatorProtocol {
viewModel = RoomMembersListScreenViewModel(roomProxy: parameters.roomProxy,
mediaProvider: parameters.mediaProvider,
userIndicatorController: parameters.userIndicatorController,
appSettings: parameters.appSettings,
analytics: parameters.analytics)
}
@@ -22,7 +22,6 @@ typealias RoomMembersListScreenViewModelType = StateStoreViewModel<RoomMembersLi
class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMembersListScreenViewModelProtocol {
private let roomProxy: RoomProxyProtocol
private let userIndicatorController: UserIndicatorControllerProtocol
private let appSettings: AppSettings
private let analytics: AnalyticsService
private var members: [RoomMemberProxyProtocol] = []
@@ -37,11 +36,9 @@ class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMe
roomProxy: RoomProxyProtocol,
mediaProvider: MediaProviderProtocol,
userIndicatorController: UserIndicatorControllerProtocol,
appSettings: AppSettings,
analytics: AnalyticsService) {
self.roomProxy = roomProxy
self.userIndicatorController = userIndicatorController
self.appSettings = appSettings
self.analytics = analytics
super.init(initialViewState: .init(joinedMembersCount: roomProxy.joinedMembersCount,
@@ -146,11 +143,6 @@ class RoomMembersListScreenViewModel: RoomMembersListScreenViewModelType, RoomMe
}
private func selectMember(_ member: RoomMemberDetails) {
guard appSettings.roomModerationEnabled else {
showMemberDetails(member)
return
}
if member.isBanned { // No need to check canBan here, banned users are only shown when it is true.
state.bindings.alertInfo = AlertInfo(id: .unbanConfirmation(member),
title: L10n.screenRoomMemberListManageMemberUnbanTitle,
@@ -111,7 +111,6 @@ private extension RoomMembersListScreenViewModel {
roomProxy: RoomProxyMock(with: .init(members: .allMembersAsAdmin)),
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics)
}
}
@@ -185,7 +185,6 @@ struct RoomMembersListScreen_Previews: PreviewProvider, TestablePreview {
canUserInvite: false)),
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics)
}
}
@@ -110,7 +110,6 @@ struct RoomMembersListMemberCell_Previews: PreviewProvider, TestablePreview {
members: members)),
mediaProvider: MockMediaProvider(),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics)
static var previews: some View {
VStack(spacing: 12) {
@@ -48,7 +48,6 @@ protocol DeveloperOptionsProtocol: AnyObject {
var otlpTracingEnabled: Bool { get set }
var shouldCollapseRoomStateEvents: Bool { get set }
var hideUnreadMessagesBadge: Bool { get set }
var roomModerationEnabled: Bool { get set }
var elementCallBaseURL: URL { get set }
var publicSearchEnabled: Bool { get set }
var qrCodeLoginEnabled: Bool { get set }
@@ -33,9 +33,6 @@ struct DeveloperOptionsScreen: View {
}
Section("Room") {
Toggle(isOn: $context.roomModerationEnabled) {
Text("Moderation")
}
Toggle(isOn: $context.shouldCollapseRoomStateEvents) {
Text("Collapse room state events")
}
@@ -475,7 +475,6 @@ class MockScreen: Identifiable {
let coordinator = RoomMembersListScreenCoordinator(parameters: .init(mediaProvider: MockMediaProvider(),
roomProxy: RoomProxyMock(with: .init(name: "test", members: members)),
userIndicatorController: ServiceLocator.shared.userIndicatorController,
appSettings: ServiceLocator.shared.settings,
analytics: ServiceLocator.shared.analytics))
navigationStackCoordinator.setRootCoordinator(coordinator)
return navigationStackCoordinator