queries/search: use flattenPages util
This commit is contained in:
parent
15594df644
commit
502f9d9f47
1 changed files with 2 additions and 5 deletions
|
@ -3,7 +3,7 @@ import { useInfiniteQuery } from '@tanstack/react-query';
|
|||
import { getNextLink } from 'soapbox/api';
|
||||
import { useApi } from 'soapbox/hooks';
|
||||
import { Account } from 'soapbox/types/entities';
|
||||
import { PaginatedResult } from 'soapbox/utils/queries';
|
||||
import { flattenPages, PaginatedResult } from 'soapbox/utils/queries';
|
||||
|
||||
export default function useAccountSearch(q: string) {
|
||||
const api = useApi();
|
||||
|
@ -42,10 +42,7 @@ export default function useAccountSearch(q: string) {
|
|||
},
|
||||
});
|
||||
|
||||
const data = queryInfo.data?.pages.reduce<Account[]>(
|
||||
(prev: Account[], curr) => [...prev, ...curr.result],
|
||||
[],
|
||||
);
|
||||
const data = flattenPages(queryInfo.data);
|
||||
|
||||
return {
|
||||
...queryInfo,
|
||||
|
|
Loading…
Reference in a new issue