forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {useMemo} from 'react'
2import {msg} from '@lingui/macro'
3import {useLingui} from '@lingui/react'
4
5import {useSetTitle} from '#/lib/hooks/useSetTitle'
6import {
7 type CommonNavigatorParams,
8 type NativeStackScreenProps,
9} from '#/lib/routes/types'
10import {useProfileQuery} from '#/state/queries/profile'
11import {useResolveDidQuery} from '#/state/queries/resolve-uri'
12import {useSession} from '#/state/session'
13import {SearchScreenShell} from '#/screens/Search/Shell'
14
15type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileSearch'>
16export const ProfileSearchScreen = ({route}: Props) => {
17 const {name, q: queryParam = ''} = route.params
18 const {_} = useLingui()
19 const {currentAccount} = useSession()
20
21 const {data: resolvedDid} = useResolveDidQuery(name)
22 const {data: profile} = useProfileQuery({did: resolvedDid})
23
24 useSetTitle(profile ? _(msg`Search @${profile.handle}'s skeets`) : undefined)
25
26 const fixedParams = useMemo(
27 () => ({
28 from: profile?.handle ?? name,
29 }),
30 [profile?.handle, name],
31 )
32
33 return (
34 <SearchScreenShell
35 navButton="back"
36 inputPlaceholder={
37 profile
38 ? currentAccount?.did === profile.did
39 ? _(msg`Search my skeets`)
40 : _(msg`Search @${profile.handle}'s skeets`)
41 : _(msg`Search...`)
42 }
43 fixedParams={fixedParams}
44 queryParam={queryParam}
45 testID="searchPostsScreen"
46 />
47 )
48}