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}) { function SearchScreenPostResults({query}: {query: string}) {
const {_} = useLingui() const {_} = useLingui()
const {currentAccount} = useSession()
const [isPTR, setIsPTR] = React.useState(false) const [isPTR, setIsPTR] = React.useState(false)
const augmentedQuery = React.useMemo(() => {
return augmentSearchQuery(query || '', {did: currentAccount?.did})
}, [query, currentAccount])
const { const {
isFetched, isFetched,
data: results, data: results,
@ -200,7 +206,7 @@ function SearchScreenPostResults({query}: {query: string}) {
fetchNextPage, fetchNextPage,
isFetchingNextPage, isFetchingNextPage,
hasNextPage, hasNextPage,
} = useSearchPostsQuery({query}) } = useSearchPostsQuery({query: augmentedQuery})
const onPullToRefresh = React.useCallback(async () => { const onPullToRefresh = React.useCallback(async () => {
setIsPTR(true) setIsPTR(true)
@ -319,13 +325,9 @@ export function SearchScreenInner({
const pal = usePalette('default') const pal = usePalette('default')
const setMinimalShellMode = useSetMinimalShellMode() const setMinimalShellMode = useSetMinimalShellMode()
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
const {hasSession, currentAccount} = useSession() const {hasSession} = useSession()
const {isDesktop} = useWebMediaQueries() const {isDesktop} = useWebMediaQueries()
const augmentedQuery = React.useMemo(() => {
return augmentSearchQuery(query || '', {did: currentAccount?.did})
}, [query, currentAccount])
const onPageSelected = React.useCallback( const onPageSelected = React.useCallback(
(index: number) => { (index: number) => {
setMinimalShellMode(false) setMinimalShellMode(false)
@ -347,7 +349,7 @@ export function SearchScreenInner({
)} )}
initialPage={0}> initialPage={0}>
<View> <View>
<SearchScreenPostResults query={augmentedQuery} /> <SearchScreenPostResults query={query} />
</View> </View>
<View> <View>
<SearchScreenUserResults query={query} /> <SearchScreenUserResults query={query} />