mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Invite people in an existing room (#915)
* Handle power levels * Add “invite” button in RoomMembersListScreen * Refactor DI in RoomDetailsScreenCoordinator * Add navigation to “select people” coordinator * Add InviteUsersScreenRoomContext * Add invite user by id api * Updare InviteUsersScreenRoomContext * Support disabled state on FormButtonStyles * Handle membership in UserProfileCell * Fix conflicts * Refactor RoomContext -> RoomType * Refactor UserProfileCell * Add invite action * Setup navigation to user flow coordinator * Add invite logic * Fix test build errors * Address comments * Fix localisations * Update required state * Handle error * Move invite logic in RoomDetailsScreenCoordinator * Add navigation from room’s members list * Fix UTs * Fix missing display name in RoomMemberDetails * Add user indicator * Add feature flag * Add RoomDetailsViewModel UTs * Add room details ui tests * Add InviteUsersViewModelTests UTs * Add UI tests * Update UI tests * Empty commit
This commit is contained in:
@@ -15,23 +15,30 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum InviteUsersScreenErrorType: Error {
|
||||
case unknown
|
||||
}
|
||||
|
||||
enum InviteUsersScreenViewModelAction {
|
||||
case close
|
||||
case proceed
|
||||
case invite(users: [String])
|
||||
case toggleUser(UserProfile)
|
||||
}
|
||||
|
||||
enum InviteUsersScreenRoomType {
|
||||
case draft
|
||||
case room(members: [RoomMemberProxyProtocol], userIndicatorController: UserIndicatorControllerProtocol)
|
||||
}
|
||||
|
||||
struct InviteUsersScreenViewState: BindableState {
|
||||
var bindings = InviteUsersScreenViewStateBindings()
|
||||
|
||||
var usersSection: UserDiscoverySection = .init(type: .suggestions, users: [])
|
||||
|
||||
var selectedUsers: [UserProfile] = []
|
||||
var membershipState: [String: MembershipState] = .init()
|
||||
|
||||
var isSearching: Bool {
|
||||
!bindings.searchQuery.isEmpty
|
||||
@@ -44,7 +51,30 @@ struct InviteUsersScreenViewState: BindableState {
|
||||
var scrollToLastID: String?
|
||||
|
||||
func isUserSelected(_ user: UserProfile) -> Bool {
|
||||
selectedUsers.contains { $0.userID == user.userID }
|
||||
isUserDisabled(user) || selectedUsers.contains { $0.userID == user.userID }
|
||||
}
|
||||
|
||||
func isUserDisabled(_ user: UserProfile) -> Bool {
|
||||
let membershipState = membershipState(user)
|
||||
return membershipState == .invite || membershipState == .join
|
||||
}
|
||||
|
||||
func membershipState(_ user: UserProfile) -> MembershipState? {
|
||||
membershipState[user.userID]
|
||||
}
|
||||
|
||||
let isCreatingRoom: Bool
|
||||
|
||||
var actionText: String {
|
||||
if isCreatingRoom {
|
||||
return selectedUsers.isEmpty ? L10n.actionSkip : L10n.actionNext
|
||||
} else {
|
||||
return L10n.actionInvite
|
||||
}
|
||||
}
|
||||
|
||||
var isActionDisabled: Bool {
|
||||
isCreatingRoom ? false : selectedUsers.isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +86,6 @@ struct InviteUsersScreenViewStateBindings {
|
||||
}
|
||||
|
||||
enum InviteUsersScreenViewAction {
|
||||
case close
|
||||
case proceed
|
||||
case toggleUser(UserProfile)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user