From 502f9d9f47309dc30125d6d20c1e05fede99ef66 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 12 Dec 2022 12:10:39 -0600 Subject: [PATCH] queries/search: use flattenPages util --- app/soapbox/queries/search.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/soapbox/queries/search.ts b/app/soapbox/queries/search.ts index 40b78a015..41c4b7fb3 100644 --- a/app/soapbox/queries/search.ts +++ b/app/soapbox/queries/search.ts @@ -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( - (prev: Account[], curr) => [...prev, ...curr.result], - [], - ); + const data = flattenPages(queryInfo.data); return { ...queryInfo,