Move query augmentation to lower component (#2748)

zio/stable
Samuel Newman 2024-02-05 23:26:08 +00:00 committed by GitHub
parent fca00d20a4
commit 6ad5863573
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 7 deletions

View File

@ -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}>
<View>
<SearchScreenPostResults query={augmentedQuery} />
<SearchScreenPostResults query={query} />
</View>
<View>
<SearchScreenUserResults query={query} />