mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
* Fixes #1950 - Show a loading indicator while searching for people to invite * Address PR comments
This commit is contained in:
parent
33d36826a2
commit
07eccbee8c
@ -41,12 +41,10 @@ struct InviteUsersScreenViewState: BindableState {
|
||||
var selectedUsers: [UserProfileProxy] = []
|
||||
var membershipState: [String: MembershipState] = .init()
|
||||
|
||||
var isSearching: Bool {
|
||||
!bindings.searchQuery.isEmpty
|
||||
}
|
||||
var isSearching = false
|
||||
|
||||
var hasEmptySearchResults: Bool {
|
||||
isSearching && usersSection.type == .searchResult && usersSection.users.isEmpty
|
||||
!isSearching && usersSection.type == .searchResult && usersSection.users.isEmpty
|
||||
}
|
||||
|
||||
var scrollToLastID: String?
|
||||
|
@ -134,6 +134,8 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
fetchSuggestions()
|
||||
return
|
||||
}
|
||||
|
||||
state.isSearching = true
|
||||
fetchUsersTask = Task {
|
||||
let result = await userDiscoveryService.searchProfiles(with: searchQuery)
|
||||
guard !Task.isCancelled else { return }
|
||||
@ -146,6 +148,8 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
state.usersSection = .init(type: .suggestions, users: [])
|
||||
return
|
||||
}
|
||||
|
||||
state.isSearching = true
|
||||
fetchUsersTask = Task {
|
||||
let result = await userDiscoveryService.fetchSuggestions()
|
||||
guard !Task.isCancelled else { return }
|
||||
@ -154,6 +158,8 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
}
|
||||
|
||||
private func handleResult(for sectionType: UserDiscoverySectionType, result: Result<[UserProfileProxy], UserDiscoveryErrorType>) {
|
||||
state.isSearching = false
|
||||
|
||||
switch result {
|
||||
case .success(let users):
|
||||
state.usersSection = .init(type: sectionType, users: users)
|
||||
|
@ -40,15 +40,22 @@ struct InviteUsersScreen: View {
|
||||
|
||||
private var mainContent: some View {
|
||||
Form {
|
||||
if !context.viewState.selectedUsers.isEmpty {
|
||||
// this is a fix for having the carousel not clipped, and inside the form, so when the search is dismissed, it wont break the design
|
||||
Section {
|
||||
EmptyView()
|
||||
} header: {
|
||||
// this is a fix for having the carousel not clipped, and inside the form, so when the search is dismissed, it wont break the design
|
||||
Section {
|
||||
EmptyView()
|
||||
} header: {
|
||||
VStack(spacing: 8) {
|
||||
selectedUsersSection
|
||||
.textCase(.none)
|
||||
|
||||
if context.viewState.isSearching {
|
||||
ProgressView()
|
||||
.frame(maxWidth: .infinity, alignment: .center)
|
||||
.listRowBackground(Color.clear)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if context.viewState.hasEmptySearchResults {
|
||||
noResultsContent
|
||||
} else {
|
||||
|
1
changelog.d/1950.change
Normal file
1
changelog.d/1950.change
Normal file
@ -0,0 +1 @@
|
||||
Show a loading indicator while searching for people to invite
|
Loading…
x
Reference in New Issue
Block a user