This commit is contained in:
Adria Navarro 2023-05-05 09:37:26 +01:00
parent 8102c54bc3
commit 2c49232fa8
1 changed files with 8 additions and 8 deletions

View File

@ -86,14 +86,14 @@
let popover let popover
let searchTerm = "" let searchTerm = ""
let prevSearch = undefined let prevSearch = undefined
let pageInfo = createPaginationStore() let searchUsersPageInfo = createPaginationStore()
let loaded = false let loaded = false
let editModal, deleteModal let editModal, deleteModal
$: scimEnabled = $features.isScimEnabled $: scimEnabled = $features.isScimEnabled
$: readonly = !$auth.isAdmin || scimEnabled $: readonly = !$auth.isAdmin || scimEnabled
$: page = $pageInfo.page $: page = $searchUsersPageInfo.page
$: fetchUsers(page, searchTerm) $: searchUsers(page, searchTerm)
$: group = $groups.find(x => x._id === groupId) $: group = $groups.find(x => x._id === groupId)
$: filtered = $users.data $: filtered = $users.data
$: groupApps = $apps $: groupApps = $apps
@ -112,20 +112,20 @@
} }
} }
async function fetchUsers(page, search) { async function searchUsers(page, search) {
if ($pageInfo.loading) { if ($searchUsersPageInfo.loading) {
return return
} }
// need to remove the page if they've started searching // need to remove the page if they've started searching
if (search && !prevSearch) { if (search && !prevSearch) {
pageInfo.reset() searchUsersPageInfo.reset()
page = undefined page = undefined
} }
prevSearch = search prevSearch = search
try { try {
pageInfo.loading() searchUsersPageInfo.loading()
await users.search({ page, email: search }) await users.search({ page, email: search })
pageInfo.fetched($users.hasNextPage, $users.nextPage) searchUsersPageInfo.fetched($users.hasNextPage, $users.nextPage)
} catch (error) { } catch (error) {
notifications.error("Error getting user list") notifications.error("Error getting user list")
} }