Skip to content

Conversation

Velin92
Copy link
Member

@Velin92 Velin92 commented Oct 16, 2025

fixes #4632

This PR allows spaces to present a their members.
Most of the PR is about extracting the existing logic of navigating through members into its own RoomMembersFlowCoordinator so that it can be reused multiple times (since it's used in the standard, room in the space, and in the future will also be used in the Space settings flow).

As of right now the flow coordinator implementation is only used in the space, but a follow up PR will soon be opened when I'll also replace the existing code present in the RoomFlowCoordinator to use this flow coordinator too.

Things left to do in this PR:

  • Await for final unified copies for ban and remove actions so that can more easily be shared between spaces and rooms.
  • Clearing the route?
  • Handling routes if necessary?
  • How to handle the continueWithSpace action if we are already inside a space.

…dular and reusable

this is required since we will need to reuse this module also in the space settings, and later we could also replace it in the RoomFlowCoordinator.
@github-actions
Copy link

github-actions bot commented Oct 16, 2025

Warnings
⚠️ You seem to have made changes to views. Please consider adding screenshots.
⚠️

ElementX/Sources/FlowCoordinators/RoomMembersFlowCoordinator.swift#L101 - TODOs should be resolved (Implement) (todo)

⚠️

ElementX/Sources/FlowCoordinators/RoomMembersFlowCoordinator.swift#L350 - TODOs should be resolved (Implement) (todo)

⚠️

ElementX/Sources/FlowCoordinators/SpaceFlowCoordinator.swift#L149 - Function should have complexity 10 or less; currently complexity is 13 (cyclomatic_complexity)

Generated by 🚫 Danger Swift against e962de3

@codecov
Copy link

codecov bot commented Oct 16, 2025

⚠️ JUnit XML file not found

The CLI was unable to find any JUnit XML files to upload.
For more help, visit our troubleshooting guide.

@Velin92 Velin92 marked this pull request as ready for review October 17, 2025 14:53
@Velin92 Velin92 requested a review from a team as a code owner October 17, 2025 14:53
@Velin92 Velin92 requested review from pixlwave and removed request for a team October 17, 2025 14:53
@Velin92 Velin92 marked this pull request as draft October 17, 2025 14:54
@Velin92 Velin92 marked this pull request as ready for review October 20, 2025 16:23
@Velin92 Velin92 added the pr-feature for a new feature label Oct 20, 2025
@sonarqubecloud
Copy link

Copy link
Member

@pixlwave pixlwave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, I love how these flow coordinators are coming together 🙌

case presentingChild(childSpaceID: String, previousState: State)
/// A room flow is in progress
case roomFlow(previousState: State)
/// A members flow in progress
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// A members flow in progress
/// A members flow is in progress

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this one is used right? Maybe we could remove it from this PR for simplicity?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this should be reverted 🙂


private func startMembersFlow() async {
guard case let .space(spaceRoomListProxy) = entryPoint,
case let .joined(roomProxy) = await flowParameters.userSession.clientProxy.roomForIdentifier(spaceRoomListProxy.id) else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much nicer for the SpaceScreen to include the JoinedRoomProxy in its displayMembers action. That's what is happening when you present a subspace and means that if you fail to get the proxy, you can show a nice error on the screen itself.

Comment on lines +64 to +68
if context.viewState.isSpaceJoined {
Button { context.send(viewAction: .displayMembers) } label: {
Label(L10n.screenSpaceMenuActionMembers, icon: \.user)
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this thing could become

Suggested change
if context.viewState.isSpaceJoined {
Button { context.send(viewAction: .displayMembers) } label: {
Label(L10n.screenSpaceMenuActionMembers, icon: \.user)
}
}
if let roomProxy = context.viewState.roomProxy {
Button { context.send(viewAction: .displayMembers(roomProxy)) } label: {
Label(L10n.screenSpaceMenuActionMembers, icon: \.user)
}
}

// TODO: Implement
}

private func configureStateMachine() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love for use to re-write this using the same Machine.addRoutes(event:transitions:handler:) and Machine.addRouteMapping(_:handler:) that we use in the SpaceFlowCoordinator. It's so much cleaner to have the route and the handler in the same place.

Comment on lines +245 to +258
case .proceed:
break
case .invite(let users):
inviteUsers(users, in: roomProxy)
case .toggleUser(let user):
var selectedUsers = selectedUsersSubject.value

if let index = selectedUsers.firstIndex(where: { $0.userID == user.userID }) {
selectedUsers.remove(at: index)
} else {
selectedUsers.append(user)
}

selectedUsersSubject.send(selectedUsers)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind moving these cases into the view model itself where they belong? Then we can remove inviteUsers showLoadingIndicator and hideLoadingIndicator from this flow.

Comment on lines +46 to +53
case presentRoomMemberDetails(userID: String)
case dismissRoomMemberDetails

case presentInviteUsersScreen
case dismissInviteUsersScreen

case presentUserProfile(userID: String)
case dismissUserProfile
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
case presentRoomMemberDetails(userID: String)
case dismissRoomMemberDetails
case presentInviteUsersScreen
case dismissInviteUsersScreen
case presentUserProfile(userID: String)
case dismissUserProfile
case presentRoomMemberDetails(userID: String)
case dismissedRoomMemberDetails
case presentInviteUsersScreen
case dismissedInviteUsersScreen
case presentUserProfile(userID: String)
case dismissedUserProfile

Comment on lines +350 to +352
// TODO: Implement
// Not sure wha to do here since this can be presented also internally by the space flow
// stateMachine.tryEvent(.startChildFlow, userInfo: SpaceFlowCoordinatorEntryPoint.space(spaceRoomListProxy))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this is not possible since only DMs can be opened up from this flow, so no need to handle it.

Comment on lines +100 to +102
func clearRoute(animated: Bool) {
// TODO: Implement
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switch state machine and clear the route accordingly (check the SpaceFlowCoordinator)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task] View and manage members in a space

2 participants