[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,25 +145,23 @@ 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} /> : (
: ( <FlatList
<FlatList data={receipts}
data={receipts} renderItem={this.renderItem}
renderItem={this.renderItem} ItemSeparatorComponent={this.renderSeparator}
ItemSeparatorComponent={this.renderSeparator} style={[
style={[ styles.list,
styles.list, {
{ backgroundColor: themes[theme].chatComponentBackground,
backgroundColor: themes[theme].chatComponentBackground, borderColor: themes[theme].separatorColor
borderColor: themes[theme].separatorColor }
} ]}
]} 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
} }
}); });