enforce uniqueness between pages on actor query
This commit is contained in:
@@ -50,9 +50,25 @@ export function useActorSearch({
|
||||
initialPageParam: undefined,
|
||||
getNextPageParam: lastPage => lastPage.cursor,
|
||||
placeholderData: maintainData ? keepPreviousData : undefined,
|
||||
select,
|
||||
})
|
||||
}
|
||||
|
||||
function select(data: InfiniteData<AppBskyActorSearchActors.OutputSchema>) {
|
||||
// enforce uniqueness
|
||||
const dids = new Set()
|
||||
for (const page of data.pages) {
|
||||
const actors = []
|
||||
for (const actor of page.actors) {
|
||||
if (dids.has(actor.did)) continue
|
||||
dids.add(actor.did)
|
||||
actors.push(actor)
|
||||
}
|
||||
page.actors = actors
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
export function* findAllProfilesInQueryData(
|
||||
queryClient: QueryClient,
|
||||
did: string,
|
||||
|
||||
Reference in New Issue
Block a user