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

View File

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