mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-17 06:25:51 +08:00
fix: get realtime groups and members data every time user open the di… (#18988)
This commit is contained in:
parent
c4729f8c20
commit
2fce4a338c
@ -25,7 +25,7 @@ export default function AddMemberOrGroupDialog() {
|
|||||||
const debouncedKeyword = useDebounce(keyword, { wait: 500 })
|
const debouncedKeyword = useDebounce(keyword, { wait: 500 })
|
||||||
|
|
||||||
const lastAvailableGroup = selectedGroupsForBreadcrumb[selectedGroupsForBreadcrumb.length - 1]
|
const lastAvailableGroup = selectedGroupsForBreadcrumb[selectedGroupsForBreadcrumb.length - 1]
|
||||||
const { isPending, isFetchingNextPage, fetchNextPage, data } = useSearchForWhiteListCandidates({ keyword: debouncedKeyword, groupId: lastAvailableGroup?.id, resultsPerPage: 10 }, open)
|
const { isLoading, isFetchingNextPage, fetchNextPage, data } = useSearchForWhiteListCandidates({ keyword: debouncedKeyword, groupId: lastAvailableGroup?.id, resultsPerPage: 10 }, open)
|
||||||
const handleKeywordChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleKeywordChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setKeyword(e.target.value)
|
setKeyword(e.target.value)
|
||||||
}
|
}
|
||||||
@ -36,13 +36,13 @@ export default function AddMemberOrGroupDialog() {
|
|||||||
let observer: IntersectionObserver | undefined
|
let observer: IntersectionObserver | undefined
|
||||||
if (anchorRef.current) {
|
if (anchorRef.current) {
|
||||||
observer = new IntersectionObserver((entries) => {
|
observer = new IntersectionObserver((entries) => {
|
||||||
if (entries[0].isIntersecting && !isPending && hasMore)
|
if (entries[0].isIntersecting && !isLoading && hasMore)
|
||||||
fetchNextPage()
|
fetchNextPage()
|
||||||
}, { rootMargin: '20px' })
|
}, { rootMargin: '20px' })
|
||||||
observer.observe(anchorRef.current)
|
observer.observe(anchorRef.current)
|
||||||
}
|
}
|
||||||
return () => observer?.disconnect()
|
return () => observer?.disconnect()
|
||||||
}, [isPending, fetchNextPage, anchorRef, data])
|
}, [isLoading, fetchNextPage, anchorRef, data])
|
||||||
|
|
||||||
return <PortalToFollowElem open={open} onOpenChange={setOpen} offset={{ crossAxis: 300 }} placement='bottom-end'>
|
return <PortalToFollowElem open={open} onOpenChange={setOpen} offset={{ crossAxis: 300 }} placement='bottom-end'>
|
||||||
<PortalToFollowElemTrigger asChild>
|
<PortalToFollowElemTrigger asChild>
|
||||||
@ -58,7 +58,7 @@ export default function AddMemberOrGroupDialog() {
|
|||||||
<Input value={keyword} onChange={handleKeywordChange} showLeftIcon placeholder={t('app.accessControlDialog.operateGroupAndMember.searchPlaceholder') as string} />
|
<Input value={keyword} onChange={handleKeywordChange} showLeftIcon placeholder={t('app.accessControlDialog.operateGroupAndMember.searchPlaceholder') as string} />
|
||||||
</div>
|
</div>
|
||||||
{
|
{
|
||||||
isPending
|
isLoading
|
||||||
? <div className='p-1'><Loading /></div>
|
? <div className='p-1'><Loading /></div>
|
||||||
: (data?.pages?.length ?? 0) > 0
|
: (data?.pages?.length ?? 0) > 0
|
||||||
? <>
|
? <>
|
||||||
|
@ -42,6 +42,8 @@ export const useSearchForWhiteListCandidates = (query: { keyword?: string; group
|
|||||||
return lastPage.currPage + 1
|
return lastPage.currPage + 1
|
||||||
return undefined
|
return undefined
|
||||||
},
|
},
|
||||||
|
gcTime: 0,
|
||||||
|
staleTime: 0,
|
||||||
enabled,
|
enabled,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user