[FIX] Read receipt crashing in some cases (#2464)

This commit is contained in:
Diego Mello 2020-09-15 10:09:23 -03:00 committed by GitHub
parent 2d22089e19
commit c61076c983
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 22 deletions

View File

@ -100,6 +100,9 @@ class ReadReceiptView extends React.Component {
Message_TimeFormat, user: { id: userId, token }, baseUrl, theme Message_TimeFormat, user: { id: userId, token }, baseUrl, theme
} = this.props; } = this.props;
const time = moment(item.ts).format(Message_TimeFormat); const time = moment(item.ts).format(Message_TimeFormat);
if (!item?.user?.username) {
return null;
}
return ( return (
<View style={[styles.itemContainer, { backgroundColor: themes[theme].backgroundColor }]}> <View style={[styles.itemContainer, { backgroundColor: themes[theme].backgroundColor }]}>
<Avatar <Avatar
@ -112,7 +115,7 @@ class ReadReceiptView extends React.Component {
<View style={styles.infoContainer}> <View style={styles.infoContainer}>
<View style={styles.item}> <View style={styles.item}>
<Text style={[styles.name, { color: themes[theme].titleText }]}> <Text style={[styles.name, { color: themes[theme].titleText }]}>
{item.user.name} {item?.user?.name}
</Text> </Text>
<Text style={{ color: themes[theme].auxiliaryText }}> <Text style={{ color: themes[theme].auxiliaryText }}>
{time} {time}
@ -142,7 +145,6 @@ class ReadReceiptView extends React.Component {
return ( return (
<SafeAreaView testID='read-receipt-view' theme={theme}> <SafeAreaView testID='read-receipt-view' theme={theme}>
<StatusBar theme={theme} /> <StatusBar theme={theme} />
<View>
{loading {loading
? <ActivityIndicator theme={theme} /> ? <ActivityIndicator theme={theme} />
: ( : (
@ -160,7 +162,6 @@ class ReadReceiptView extends React.Component {
keyExtractor={item => item._id} keyExtractor={item => item._id}
/> />
)} )}
</View>
</SafeAreaView> </SafeAreaView>
); );
} }

View File

@ -29,7 +29,6 @@ export default StyleSheet.create({
padding: 10 padding: 10
}, },
list: { list: {
...sharedStyles.separatorVertical, ...sharedStyles.separatorVertical
marginVertical: 10
} }
}); });