Invite the DM recipient to a new room (#5588)

* handle the details to invite users flow.

* implemented the room creation in the invite screen, and its dismissal + navigaton to the newly created room

* updated preview and unit tests

* pr suggestions
This commit is contained in:
Mauro
2026-05-18 10:08:07 +02:00
committed by GitHub
parent 9ed47c61b7
commit 6c0aaa7a58
39 changed files with 297 additions and 100 deletions
@@ -16,11 +16,12 @@ enum InviteUsersScreenErrorType: Error {
enum InviteUsersScreenViewModelAction {
case dismiss
case openRoom(roomID: String)
}
enum InviteUsersScreenRoomType {
case draft
case room(roomProxy: JoinedRoomProxyProtocol)
case draft(mandatoryInvitees: [UserProfileProxy])
case existingRoom(roomProxy: JoinedRoomProxyProtocol)
}
struct InviteUsersScreenViewState: BindableState {
@@ -29,6 +30,7 @@ struct InviteUsersScreenViewState: BindableState {
var usersSection: UserDiscoverySection = .init(type: .suggestions, users: [])
var selectedUsers: [UserProfileProxy] = []
var mandatoryInvitees: [UserProfileProxy] = []
var membershipState: [String: MembershipState] = .init()
var usersToConfirm: [UserProfileProxy] = []
@@ -38,32 +40,29 @@ struct InviteUsersScreenViewState: BindableState {
!isSearching && usersSection.type == .searchResult && usersSection.users.isEmpty
}
var hasInvitableSelectedUsers: Bool {
selectedUsers.contains { !isInviteeMandatory($0) }
}
func isUserSelected(_ user: UserProfileProxy) -> Bool {
isUserDisabled(user) || selectedUsers.contains { $0.userID == user.userID }
}
func isUserDisabled(_ user: UserProfileProxy) -> Bool {
if isInviteeMandatory(user) { return true }
let membershipState = membershipState(user)
return membershipState == .invite || membershipState == .join
}
func isInviteeMandatory(_ user: UserProfileProxy) -> Bool {
mandatoryInvitees.contains { $0.userID == user.userID }
}
func membershipState(_ user: UserProfileProxy) -> MembershipState? {
membershipState[user.userID]
}
let isSkippable: Bool
var actionText: String {
if isSkippable, selectedUsers.isEmpty {
L10n.actionSkip
} else {
L10n.actionInvite
}
}
var isActionDisabled: Bool {
isSkippable ? false : selectedUsers.isEmpty
}
}
struct InviteUsersScreenViewStateBindings {