Search page (#1969)
parent
47d2d3cbf2
commit
8da10a5edc
|
@ -6,6 +6,7 @@ import {
|
||||||
RefreshControl,
|
RefreshControl,
|
||||||
TextInput,
|
TextInput,
|
||||||
Pressable,
|
Pressable,
|
||||||
|
Platform,
|
||||||
} from 'react-native'
|
} from 'react-native'
|
||||||
import {FlatList, ScrollView, CenteredView} from '#/view/com/util/Views'
|
import {FlatList, ScrollView, CenteredView} from '#/view/com/util/Views'
|
||||||
import {AppBskyActorDefs, AppBskyFeedDefs, moderateProfile} from '@atproto/api'
|
import {AppBskyActorDefs, AppBskyFeedDefs, moderateProfile} from '@atproto/api'
|
||||||
|
@ -284,10 +285,17 @@ function SearchScreenUserResults({query}: {query: string}) {
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
async function getResults() {
|
async function getResults() {
|
||||||
|
try {
|
||||||
const searchResults = await search({query, limit: 30})
|
const searchResults = await search({query, limit: 30})
|
||||||
|
|
||||||
if (searchResults) {
|
if (searchResults) {
|
||||||
setResults(results)
|
setResults(searchResults)
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
logger.error(`SearchScreenUserResults: failed to get results`, {
|
||||||
|
error: e.toString(),
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
setIsFetched(true)
|
setIsFetched(true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +306,7 @@ function SearchScreenUserResults({query}: {query: string}) {
|
||||||
setResults([])
|
setResults([])
|
||||||
setIsFetched(false)
|
setIsFetched(false)
|
||||||
}
|
}
|
||||||
}, [query, search, results])
|
}, [query, search, setResults])
|
||||||
|
|
||||||
return isFetched ? (
|
return isFetched ? (
|
||||||
<>
|
<>
|
||||||
|
@ -327,6 +335,8 @@ 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()
|
||||||
|
const {hasSession} = useSession()
|
||||||
|
const {isDesktop} = useWebMediaQueries()
|
||||||
|
|
||||||
const onPageSelected = React.useCallback(
|
const onPageSelected = React.useCallback(
|
||||||
(index: number) => {
|
(index: number) => {
|
||||||
|
@ -353,7 +363,7 @@ export function SearchScreenInner({query}: {query?: string}) {
|
||||||
<SearchScreenUserResults query={query} />
|
<SearchScreenUserResults query={query} />
|
||||||
</View>
|
</View>
|
||||||
</Pager>
|
</Pager>
|
||||||
) : (
|
) : hasSession ? (
|
||||||
<View>
|
<View>
|
||||||
<CenteredView sideBorders style={pal.border}>
|
<CenteredView sideBorders style={pal.border}>
|
||||||
<Text
|
<Text
|
||||||
|
@ -371,8 +381,43 @@ export function SearchScreenInner({query}: {query?: string}) {
|
||||||
<Trans>Suggested Follows</Trans>
|
<Trans>Suggested Follows</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</CenteredView>
|
</CenteredView>
|
||||||
|
|
||||||
<SearchScreenSuggestedFollows />
|
<SearchScreenSuggestedFollows />
|
||||||
</View>
|
</View>
|
||||||
|
) : (
|
||||||
|
<CenteredView sideBorders style={pal.border}>
|
||||||
|
<View
|
||||||
|
// @ts-ignore web only -esb
|
||||||
|
style={{
|
||||||
|
height: Platform.select({web: '100vh'}),
|
||||||
|
}}>
|
||||||
|
{isDesktop && (
|
||||||
|
<Text
|
||||||
|
type="title"
|
||||||
|
style={[
|
||||||
|
pal.text,
|
||||||
|
pal.border,
|
||||||
|
{
|
||||||
|
display: 'flex',
|
||||||
|
paddingVertical: 12,
|
||||||
|
paddingHorizontal: 18,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<Trans>Search</Trans>
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<Text
|
||||||
|
style={[
|
||||||
|
pal.textLight,
|
||||||
|
{textAlign: 'center', paddingVertical: 12, paddingHorizontal: 18},
|
||||||
|
]}>
|
||||||
|
<Trans>Search for posts and users.</Trans>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</CenteredView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue