From 6ad5863573d5117a58630e9ed62746872ef7185c Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Mon, 5 Feb 2024 23:26:08 +0000 Subject: [PATCH] Move query augmentation to lower component (#2748) --- src/view/screens/Search/Search.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/view/screens/Search/Search.tsx b/src/view/screens/Search/Search.tsx index 36e6dcff..14272670 100644 --- a/src/view/screens/Search/Search.tsx +++ b/src/view/screens/Search/Search.tsx @@ -190,7 +190,13 @@ type SearchResultSlice = function SearchScreenPostResults({query}: {query: string}) { const {_} = useLingui() + const {currentAccount} = useSession() const [isPTR, setIsPTR] = React.useState(false) + + const augmentedQuery = React.useMemo(() => { + return augmentSearchQuery(query || '', {did: currentAccount?.did}) + }, [query, currentAccount]) + const { isFetched, data: results, @@ -200,7 +206,7 @@ function SearchScreenPostResults({query}: {query: string}) { fetchNextPage, isFetchingNextPage, hasNextPage, - } = useSearchPostsQuery({query}) + } = useSearchPostsQuery({query: augmentedQuery}) const onPullToRefresh = React.useCallback(async () => { setIsPTR(true) @@ -319,13 +325,9 @@ export function SearchScreenInner({ const pal = usePalette('default') const setMinimalShellMode = useSetMinimalShellMode() const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() - const {hasSession, currentAccount} = useSession() + const {hasSession} = useSession() const {isDesktop} = useWebMediaQueries() - const augmentedQuery = React.useMemo(() => { - return augmentSearchQuery(query || '', {did: currentAccount?.did}) - }, [query, currentAccount]) - const onPageSelected = React.useCallback( (index: number) => { setMinimalShellMode(false) @@ -347,7 +349,7 @@ export function SearchScreenInner({ )} initialPage={0}> - +