do not fail if a message has a list of empty attachment

pull/1381/head
Audric Ackermann 5 years ago
parent f28dfe5a94
commit 4a58b2c9f6
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -174,8 +174,14 @@ class SessionRightPanel extends React.Component<Props, State> {
// Unlike visual media, only one non-image attachment is supported // Unlike visual media, only one non-image attachment is supported
const documents = rawDocuments.map( const documents = rawDocuments.map(
(message: { attachments: Array<any> }) => { (message: { attachments: Array<any> }) => {
const attachments = message.attachments || []; // this is to not fail if the attachment is invalid (could be a Long Attachment type which is not supported)
const attachment = attachments[0]; if (!message.attachments?.length) {
window.log.info(
'Got a message with an empty list of attachment. Skipping...'
);
return null;
}
const attachment = message.attachments[0];
return { return {
contentType: attachment.contentType, contentType: attachment.contentType,
@ -220,7 +226,7 @@ class SessionRightPanel extends React.Component<Props, State> {
return { return {
media, media,
documents, documents: _.compact(documents), // remove null
onItemClick, onItemClick,
}; };
} }

Loading…
Cancel
Save