mirror of
https://github.com/tooot-app/app
synced 2025-06-05 22:19:13 +02:00
Clean up react memo
This commit is contained in:
@ -8,65 +8,62 @@ import React from 'react'
|
||||
import { Pressable, StyleSheet, Text, View } from 'react-native'
|
||||
|
||||
export interface Props {
|
||||
card: Mastodon.Card
|
||||
card: Pick<
|
||||
Mastodon.Card,
|
||||
'url' | 'image' | 'blurhash' | 'title' | 'description'
|
||||
>
|
||||
}
|
||||
|
||||
const TimelineCard = React.memo(
|
||||
({ card }: Props) => {
|
||||
const { colors } = useTheme()
|
||||
const navigation = useNavigation()
|
||||
const TimelineCard = React.memo(({ card }: Props) => {
|
||||
const { colors } = useTheme()
|
||||
const navigation = useNavigation()
|
||||
|
||||
return (
|
||||
<Pressable
|
||||
accessible
|
||||
accessibilityRole='link'
|
||||
style={[styles.card, { borderColor: colors.border }]}
|
||||
onPress={async () => {
|
||||
analytics('timeline_shared_card_press')
|
||||
await openLink(card.url, navigation)
|
||||
}}
|
||||
testID='base'
|
||||
>
|
||||
{card.image ? (
|
||||
<GracefullyImage
|
||||
uri={{ original: card.image }}
|
||||
blurhash={card.blurhash}
|
||||
style={styles.left}
|
||||
imageStyle={styles.image}
|
||||
/>
|
||||
) : null}
|
||||
<View style={styles.right}>
|
||||
<Text
|
||||
numberOfLines={2}
|
||||
style={[styles.rightTitle, { color: colors.primaryDefault }]}
|
||||
testID='title'
|
||||
>
|
||||
{card.title}
|
||||
</Text>
|
||||
{card.description ? (
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={[
|
||||
styles.rightDescription,
|
||||
{ color: colors.primaryDefault }
|
||||
]}
|
||||
testID='description'
|
||||
>
|
||||
{card.description}
|
||||
</Text>
|
||||
) : null}
|
||||
return (
|
||||
<Pressable
|
||||
accessible
|
||||
accessibilityRole='link'
|
||||
style={[styles.card, { borderColor: colors.border }]}
|
||||
onPress={async () => {
|
||||
analytics('timeline_shared_card_press')
|
||||
await openLink(card.url, navigation)
|
||||
}}
|
||||
testID='base'
|
||||
>
|
||||
{card.image ? (
|
||||
<GracefullyImage
|
||||
uri={{ original: card.image }}
|
||||
blurhash={card.blurhash}
|
||||
style={styles.left}
|
||||
imageStyle={styles.image}
|
||||
/>
|
||||
) : null}
|
||||
<View style={styles.right}>
|
||||
<Text
|
||||
numberOfLines={2}
|
||||
style={[styles.rightTitle, { color: colors.primaryDefault }]}
|
||||
testID='title'
|
||||
>
|
||||
{card.title}
|
||||
</Text>
|
||||
{card.description ? (
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={[styles.rightLink, { color: colors.secondary }]}
|
||||
style={[styles.rightDescription, { color: colors.primaryDefault }]}
|
||||
testID='description'
|
||||
>
|
||||
{card.url}
|
||||
{card.description}
|
||||
</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
},
|
||||
() => true
|
||||
)
|
||||
) : null}
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={[styles.rightLink, { color: colors.secondary }]}
|
||||
>
|
||||
{card.url}
|
||||
</Text>
|
||||
</View>
|
||||
</Pressable>
|
||||
)
|
||||
})
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
card: {
|
||||
|
Reference in New Issue
Block a user