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 {getTerminology, TERMINOLOGY} from '#/lib/strings/terminology'
7import {useTerminologyPreference} from '#/state/preferences'
8import {
9 type CommonNavigatorParams,
10 type NativeStackScreenProps,
11} from '#/lib/routes/types'
12import {useProfileQuery} from '#/state/queries/profile'
13import {useResolveDidQuery} from '#/state/queries/resolve-uri'
14import {useSession} from '#/state/session'
15import {SearchScreenShell} from '#/screens/Search/Shell'
16
17type Props = NativeStackScreenProps<CommonNavigatorParams, 'ProfileSearch'>
18export const ProfileSearchScreen = ({route}: Props) => {
19 const {name, q: queryParam = ''} = route.params
20 const {_} = useLingui()
21 const terminologyPreference = useTerminologyPreference()
22 const {currentAccount} = useSession()
23
24 const {data: resolvedDid} = useResolveDidQuery(name)
25 const {data: profile} = useProfileQuery({did: resolvedDid})
26
27 useSetTitle(profile ? _(getTerminology(terminologyPreference, TERMINOLOGY.searchProfile(profile.handle))) : undefined)
28
29 const fixedParams = useMemo(
30 () => ({
31 from: profile?.handle ?? name,
32 }),
33 [profile?.handle, name],
34 )
35
36 return (
37 <SearchScreenShell
38 navButton="back"
39 inputPlaceholder={
40 profile
41 ? currentAccount?.did === profile.did
42 ? _(getTerminology(terminologyPreference, TERMINOLOGY.searchMy))
43 : _(getTerminology(terminologyPreference, TERMINOLOGY.searchProfile(profile.handle)))
44 : _(msg`Search...`)
45 }
46 fixedParams={fixedParams}
47 queryParam={queryParam}
48 testID="searchPostsScreen"
49 />
50 )
51}