Skip to content

Commit

Permalink
Final design for pending members when changing roles. (#2668)
Browse files Browse the repository at this point in the history
* Final design for pending users when changing role.

* Remove room moderation feature flag.

* Fix tests.

* Run periphery.

* Update snapshots.
  • Loading branch information
pixlwave authored Apr 9, 2024
1 parent c61135f commit 0856891
Show file tree
Hide file tree
Showing 33 changed files with 58 additions and 126 deletions.
2 changes: 1 addition & 1 deletion ElementX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7372,7 +7372,7 @@
repositoryURL = "https://github.com/element-hq/compound-ios";
requirement = {
kind = revision;
revision = 6d42477c54a1dae128e0cb3645e3d00a53a5736c;
revision = 5c8ee9be606768ad228d61aa3508df515f208908;
};
};
F76A08D0EA29A07A54F4EB4D /* XCRemoteSwiftPackageReference "swift-collections" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/element-hq/compound-ios",
"state" : {
"revision" : "6d42477c54a1dae128e0cb3645e3d00a53a5736c"
"revision" : "5c8ee9be606768ad228d61aa3508df515f208908"
}
},
{
Expand Down Expand Up @@ -263,7 +263,7 @@
{
"identity" : "swiftui-introspect",
"kind" : "remoteSourceControl",
"location" : "https://github.com/siteline/SwiftUI-Introspect.git",
"location" : "https://github.com/siteline/SwiftUI-Introspect",
"state" : {
"revision" : "b94da693e57eaf79d16464b8b7c90d09cba4e290",
"version" : "0.9.2"
Expand Down
4 changes: 0 additions & 4 deletions ElementX/Sources/Application/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ final class AppSettings {
case roomListFiltersEnabled
case markAsUnreadEnabled
case markAsFavouriteEnabled
case roomModerationEnabled
case publicSearchEnabled
case qrCodeLoginEnabled
}
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,20 @@ import MatrixRustSDK
import SwiftUI

struct RoomChangeRolesScreenRow: View {
@Environment(\.isEnabled) private var isEnabled

let member: RoomMemberDetails
let imageProvider: ImageProviderProtocol?

let isSelected: Bool
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ struct RoomDetailsScreenCoordinatorParameters {
let userIndicatorController: UserIndicatorControllerProtocol
let notificationSettings: NotificationSettingsProxyProtocol
let attributedStringBuilder: AttributedStringBuilderProtocol
let appSettings: AppSettings
}

enum RoomDetailsScreenCoordinatorAction {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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?

Expand All @@ -43,16 +42,14 @@ 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
self.analyticsService = analyticsService
self.userIndicatorController = userIndicatorController
self.notificationSettingsProxy = notificationSettingsProxy
self.attributedStringBuilder = attributedStringBuilder
self.appSettings = appSettings

let topic = attributedStringBuilder.fromPlain(roomProxy.topic)

Expand Down Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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 = {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ struct RoomMembersListScreenCoordinatorParameters {
let mediaProvider: MediaProviderProtocol
let roomProxy: RoomProxyProtocol
let userIndicatorController: UserIndicatorControllerProtocol
let appSettings: AppSettings
let analytics: AnalyticsService
}

Expand All @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ struct DeveloperOptionsScreen: View {
}

Section("Room") {
Toggle(isOn: $context.roomModerationEnabled) {
Text("Moderation")
}
Toggle(isOn: $context.shouldCollapseRoomStateEvents) {
Text("Collapse room state events")
}
Expand Down
1 change: 0 additions & 1 deletion ElementX/Sources/UITests/UITestsAppCoordinator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 0856891

Please sign in to comment.