[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,25 +145,23 @@ class ReadReceiptView extends React.Component {
return (
<SafeAreaView testID='read-receipt-view' theme={theme}>
<StatusBar theme={theme} />
<View>
{loading
? <ActivityIndicator theme={theme} />
: (
<FlatList
data={receipts}
renderItem={this.renderItem}
ItemSeparatorComponent={this.renderSeparator}
style={[
styles.list,
{
backgroundColor: themes[theme].chatComponentBackground,
borderColor: themes[theme].separatorColor
}
]}
keyExtractor={item => item._id}
/>
)}
</View>
{loading
? <ActivityIndicator theme={theme} />
: (
<FlatList
data={receipts}
renderItem={this.renderItem}
ItemSeparatorComponent={this.renderSeparator}
style={[
styles.list,
{
backgroundColor: themes[theme].chatComponentBackground,
borderColor: themes[theme].separatorColor
}
]}
keyExtractor={item => item._id}
/>
)}
</SafeAreaView>
);
}

View File

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