rename everything to query temporarily

This commit is contained in:
Hailey
2024-04-24 10:33:25 -07:00
parent ace0cb3ac9
commit a03ab3e9d5
+29 -32
View File
@@ -252,11 +252,11 @@ type SearchResultSlice =
} }
function SearchScreenPostResults({ function SearchScreenPostResults({
queryTerm, query,
sort, sort,
active, active,
}: { }: {
queryTerm: string query: string
sort?: 'top' | 'latest' sort?: 'top' | 'latest'
active: boolean active: boolean
}) { }) {
@@ -265,8 +265,8 @@ function SearchScreenPostResults({
const [isPTR, setIsPTR] = React.useState(false) const [isPTR, setIsPTR] = React.useState(false)
const augmentedQuery = React.useMemo(() => { const augmentedQuery = React.useMemo(() => {
return augmentSearchQuery(queryTerm || '', {did: currentAccount?.did}) return augmentSearchQuery(query || '', {did: currentAccount?.did})
}, [queryTerm, currentAccount]) }, [query, currentAccount])
const { const {
isFetched, isFetched,
@@ -348,7 +348,7 @@ function SearchScreenPostResults({
contentContainerStyle={{paddingBottom: 100}} contentContainerStyle={{paddingBottom: 100}}
/> />
) : ( ) : (
<EmptyState message={_(msg`No results found for ${queryTerm}`)} /> <EmptyState message={_(msg`No results found for ${query}`)} />
)} )}
</> </>
) : ( ) : (
@@ -359,16 +359,16 @@ function SearchScreenPostResults({
} }
function SearchScreenUserResults({ function SearchScreenUserResults({
queryTerm, query,
active, active,
}: { }: {
queryTerm: string query: string
active: boolean active: boolean
}) { }) {
const {_} = useLingui() const {_} = useLingui()
const {data: results, isFetched} = useActorSearch({ const {data: results, isFetched} = useActorSearch({
query: queryTerm, query: query,
enabled: active, enabled: active,
}) })
@@ -386,7 +386,7 @@ function SearchScreenUserResults({
contentContainerStyle={{paddingBottom: 100}} contentContainerStyle={{paddingBottom: 100}}
/> />
) : ( ) : (
<EmptyState message={_(msg`No results found for ${queryTerm}`)} /> <EmptyState message={_(msg`No results found for ${query}`)} />
)} )}
</> </>
) : ( ) : (
@@ -394,7 +394,7 @@ function SearchScreenUserResults({
) )
} }
export function SearchScreenInner({queryTerm}: {queryTerm?: string}) { export function SearchScreenInner({query}: {query?: string}) {
const pal = usePalette('default') const pal = usePalette('default')
const setMinimalShellMode = useSetMinimalShellMode() const setMinimalShellMode = useSetMinimalShellMode()
const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled() const setDrawerSwipeDisabled = useSetDrawerSwipeDisabled()
@@ -413,13 +413,13 @@ export function SearchScreenInner({queryTerm}: {queryTerm?: string}) {
) )
const sections = React.useMemo(() => { const sections = React.useMemo(() => {
if (!queryTerm) return [] if (!query) return []
return [ return [
{ {
title: _(msg`Top`), title: _(msg`Top`),
component: ( component: (
<SearchScreenPostResults <SearchScreenPostResults
queryTerm={queryTerm} query={query}
sort="top" sort="top"
active={activeTab === 0} active={activeTab === 0}
/> />
@@ -429,7 +429,7 @@ export function SearchScreenInner({queryTerm}: {queryTerm?: string}) {
title: _(msg`Latest`), title: _(msg`Latest`),
component: ( component: (
<SearchScreenPostResults <SearchScreenPostResults
queryTerm={queryTerm} query={query}
sort="latest" sort="latest"
active={activeTab === 1} active={activeTab === 1}
/> />
@@ -438,16 +438,13 @@ export function SearchScreenInner({queryTerm}: {queryTerm?: string}) {
{ {
title: _(msg`People`), title: _(msg`People`),
component: ( component: (
<SearchScreenUserResults <SearchScreenUserResults query={query} active={activeTab === 2} />
queryTerm={queryTerm}
active={activeTab === 2}
/>
), ),
}, },
] ]
}, [_, queryTerm, activeTab]) }, [_, query, activeTab])
return queryTerm ? ( return query ? (
<Pager <Pager
onPageSelected={onPageSelected} onPageSelected={onPageSelected}
renderTabBar={props => ( renderTabBar={props => (
@@ -546,7 +543,7 @@ export function SearchScreen(
// Query terms // Query terms
const q = props.route?.params?.q ?? '' const q = props.route?.params?.q ?? ''
const [queryTerm, setQueryTerm] = React.useState<string>(q) const [query, setQuery] = React.useState<string>(q)
const [searchText, setSearchText] = React.useState<string>(q) const [searchText, setSearchText] = React.useState<string>(q)
const throttledInput = useThrottledValue(searchText, 300) const throttledInput = useThrottledValue(searchText, 300)
@@ -558,8 +555,8 @@ export function SearchScreen(
const [inputIsFocused, setInputIsFocused] = React.useState(false) const [inputIsFocused, setInputIsFocused] = React.useState(false)
const [searchHistory, setSearchHistory] = React.useState<string[]>([]) const [searchHistory, setSearchHistory] = React.useState<string[]>([])
if (q !== queryTerm) { if (q !== query) {
setQueryTerm(q) setQuery(q)
setSearchText(q) setSearchText(q)
} }
@@ -603,17 +600,17 @@ export function SearchScreen(
scrollToTopWeb() scrollToTopWeb()
if (inputIsFocused) { if (inputIsFocused) {
setSearchText(queryTerm) setSearchText(query)
// setInputIsFocused(false) // setInputIsFocused(false)
textInput.current?.blur() textInput.current?.blur()
} else { } else {
if (isWeb && queryTerm) { if (isWeb && query) {
navigation.goBack() navigation.goBack()
} else { } else {
navigation.setParams({q: ''}) navigation.setParams({q: ''})
} }
} }
}, [inputIsFocused, navigation, queryTerm]) }, [inputIsFocused, navigation, query])
const onChangeText = React.useCallback(async (text: string) => { const onChangeText = React.useCallback(async (text: string) => {
scrollToTopWeb() scrollToTopWeb()
@@ -647,7 +644,7 @@ export function SearchScreen(
const onSubmit = React.useCallback(() => { const onSubmit = React.useCallback(() => {
scrollToTopWeb() scrollToTopWeb()
updateSearchHistory(searchText) updateSearchHistory(searchText)
setQueryTerm(searchText) setQuery(searchText)
if (isWeb) { if (isWeb) {
navigation.push('Search', {q: searchText}) navigation.push('Search', {q: searchText})
@@ -662,9 +659,9 @@ export function SearchScreen(
}, [onPressCancelSearch]) }, [onPressCancelSearch])
const queryMaybeHandle = React.useMemo(() => { const queryMaybeHandle = React.useMemo(() => {
const match = MATCH_HANDLE.exec(queryTerm) const match = MATCH_HANDLE.exec(query)
return match && match[1] return match && match[1]
}, [queryTerm]) }, [query])
useFocusEffect( useFocusEffect(
React.useCallback(() => { React.useCallback(() => {
@@ -674,7 +671,7 @@ export function SearchScreen(
) )
const handleHistoryItemClick = (item: React.SetStateAction<string>) => { const handleHistoryItemClick = (item: React.SetStateAction<string>) => {
setQueryTerm(item) setQuery(item)
onSubmit() onSubmit()
} }
@@ -772,7 +769,7 @@ export function SearchScreen(
) : undefined} ) : undefined}
</View> </View>
{(queryTerm || inputIsFocused) && ( {(query || inputIsFocused) && (
<View style={styles.headerCancelBtn}> <View style={styles.headerCancelBtn}>
<Pressable <Pressable
onPress={onPressCancelSearch} onPress={onPressCancelSearch}
@@ -832,7 +829,7 @@ export function SearchScreen(
</ScrollView> </ScrollView>
)} )}
</> </>
) : !queryTerm && inputIsFocused ? ( ) : !query && inputIsFocused ? (
<CenteredView <CenteredView
sideBorders={isTabletOrDesktop} sideBorders={isTabletOrDesktop}
// @ts-ignore web only -prf // @ts-ignore web only -prf
@@ -877,7 +874,7 @@ export function SearchScreen(
</View> </View>
</CenteredView> </CenteredView>
) : ( ) : (
<SearchScreenInner queryTerm={queryTerm} /> <SearchScreenInner query={query} />
)} )}
</View> </View>
) )