2020-11-28 17:07:30 +01:00
|
|
|
import React, { useCallback } from 'react'
|
2020-12-13 14:04:25 +01:00
|
|
|
import { StyleConstants } from '@utils/styles/constants'
|
2020-12-18 00:00:45 +01:00
|
|
|
import { useNavigation } from '@react-navigation/native'
|
2021-01-07 19:13:09 +01:00
|
|
|
import { QueryKeyTimeline } from '@utils/queryHooks/timeline'
|
2021-01-16 00:00:31 +01:00
|
|
|
import GracefullyImage from '@components/GracefullyImage'
|
2021-01-24 02:25:43 +01:00
|
|
|
import { StackNavigationProp } from '@react-navigation/stack'
|
|
|
|
import analytics from '@components/analytics'
|
2020-11-23 00:07:32 +01:00
|
|
|
|
2020-10-31 21:04:46 +01:00
|
|
|
export interface Props {
|
2021-01-07 19:13:09 +01:00
|
|
|
queryKey?: QueryKeyTimeline
|
2020-12-03 01:28:56 +01:00
|
|
|
account: Mastodon.Account
|
2020-10-31 21:04:46 +01:00
|
|
|
}
|
|
|
|
|
2020-12-14 22:33:19 +01:00
|
|
|
const TimelineAvatar: React.FC<Props> = ({ queryKey, account }) => {
|
2021-01-24 02:25:43 +01:00
|
|
|
const navigation = useNavigation<
|
2021-01-30 01:29:15 +01:00
|
|
|
StackNavigationProp<Nav.TabLocalStackParamList>
|
2021-01-24 02:25:43 +01:00
|
|
|
>()
|
2020-10-30 00:49:05 +01:00
|
|
|
// Need to fix go back root
|
2020-11-28 17:07:30 +01:00
|
|
|
const onPress = useCallback(() => {
|
2021-01-30 01:29:15 +01:00
|
|
|
analytics('timeline_shared_avatar_press', {
|
|
|
|
page: queryKey && queryKey[1].page
|
|
|
|
})
|
|
|
|
queryKey && navigation.push('Tab-Shared-Account', { account })
|
2020-11-28 17:07:30 +01:00
|
|
|
}, [])
|
|
|
|
|
2020-10-28 00:02:37 +01:00
|
|
|
return (
|
2021-01-16 00:00:31 +01:00
|
|
|
<GracefullyImage
|
|
|
|
onPress={onPress}
|
|
|
|
uri={{ original: account.avatar_static }}
|
|
|
|
dimension={{
|
|
|
|
width: StyleConstants.Avatar.M,
|
|
|
|
height: StyleConstants.Avatar.M
|
|
|
|
}}
|
|
|
|
style={{
|
|
|
|
borderRadius: 4,
|
|
|
|
overflow: 'hidden',
|
|
|
|
marginRight: StyleConstants.Spacing.S
|
|
|
|
}}
|
|
|
|
/>
|
2020-10-28 00:02:37 +01:00
|
|
|
)
|
2020-10-25 01:35:41 +02:00
|
|
|
}
|
|
|
|
|
2020-12-03 01:28:56 +01:00
|
|
|
export default React.memo(TimelineAvatar, () => true)
|