Add link behaviors to search screen suggestions
parent
75f801ed71
commit
2271112317
|
@ -12,6 +12,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||||
import {observer} from 'mobx-react-lite'
|
import {observer} from 'mobx-react-lite'
|
||||||
import _omit from 'lodash.omit'
|
import _omit from 'lodash.omit'
|
||||||
import {ErrorScreen} from '../util/ErrorScreen'
|
import {ErrorScreen} from '../util/ErrorScreen'
|
||||||
|
import {Link} from '../util/Link'
|
||||||
import {UserAvatar} from '../util/UserAvatar'
|
import {UserAvatar} from '../util/UserAvatar'
|
||||||
import Toast from '../util/Toast'
|
import Toast from '../util/Toast'
|
||||||
import {useStores} from '../../../state'
|
import {useStores} from '../../../state'
|
||||||
|
@ -23,7 +24,13 @@ import {
|
||||||
import {s, colors, gradients} from '../../lib/styles'
|
import {s, colors, gradients} from '../../lib/styles'
|
||||||
|
|
||||||
export const SuggestedFollows = observer(
|
export const SuggestedFollows = observer(
|
||||||
({onNoSuggestions}: {onNoSuggestions?: () => void}) => {
|
({
|
||||||
|
onNoSuggestions,
|
||||||
|
asLinks,
|
||||||
|
}: {
|
||||||
|
onNoSuggestions?: () => void
|
||||||
|
asLinks?: boolean
|
||||||
|
}) => {
|
||||||
const store = useStores()
|
const store = useStores()
|
||||||
const [follows, setFollows] = useState<Record<string, string>>({})
|
const [follows, setFollows] = useState<Record<string, string>>({})
|
||||||
|
|
||||||
|
@ -75,14 +82,30 @@ export const SuggestedFollows = observer(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderItem = ({item}: {item: SuggestedActor}) => (
|
const renderItem = ({item}: {item: SuggestedActor}) => {
|
||||||
<User
|
if (asLinks) {
|
||||||
item={item}
|
return (
|
||||||
follow={follows[item.did]}
|
<Link
|
||||||
onPressFollow={onPressFollow}
|
href={`/profile/${item.handle}`}
|
||||||
onPressUnfollow={onPressUnfollow}
|
title={item.displayName || item.handle}>
|
||||||
/>
|
<User
|
||||||
)
|
item={item}
|
||||||
|
follow={follows[item.did]}
|
||||||
|
onPressFollow={onPressFollow}
|
||||||
|
onPressUnfollow={onPressUnfollow}
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<User
|
||||||
|
item={item}
|
||||||
|
follow={follows[item.did]}
|
||||||
|
onPressFollow={onPressFollow}
|
||||||
|
onPressUnfollow={onPressUnfollow}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
{view.isLoading ? (
|
{view.isLoading ? (
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const Search = ({visible, params}: ScreenParams) => {
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.heading}>Suggested follows</Text>
|
<Text style={styles.heading}>Suggested follows</Text>
|
||||||
<SuggestedFollows />
|
<SuggestedFollows asLinks />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue