Fix Plerooma search crash

Potentially could be crashing in other scenarios where history data is missing
This commit is contained in:
xmflsct 2022-12-21 15:31:18 +01:00
parent 5e90a0d8f3
commit 10f7d74600
1 changed files with 18 additions and 16 deletions

View File

@ -52,22 +52,24 @@ const ComponentHashtag: React.FC<PropsWithChildren & Props> = ({
> >
#{hashtag.name} #{hashtag.name}
</CustomText> </CustomText>
<View {hashtag.history?.length ? (
style={{ flexDirection: 'row', alignItems: 'center', alignSelf: 'stretch' }} <View
onLayout={({ style={{ flexDirection: 'row', alignItems: 'center', alignSelf: 'stretch' }}
nativeEvent: { onLayout={({
layout: { height } nativeEvent: {
} layout: { height }
}) => setHeight(height)} }
> }) => setHeight(height)}
<Sparkline >
data={hashtag.history?.map(h => parseInt(h.uses)).reverse()} <Sparkline
width={width} data={hashtag.history.map(h => parseInt(h.uses)).reverse()}
height={height} width={width}
margin={children ? StyleConstants.Spacing.S : undefined} height={height}
/> margin={children ? StyleConstants.Spacing.S : undefined}
{children} />
</View> {children}
</View>
) : null}
</Pressable> </Pressable>
) )
} }