diff --git a/ts/components/session/conversation/SessionRightPanel.tsx b/ts/components/session/conversation/SessionRightPanel.tsx index 98d253291..a3321559f 100644 --- a/ts/components/session/conversation/SessionRightPanel.tsx +++ b/ts/components/session/conversation/SessionRightPanel.tsx @@ -174,8 +174,14 @@ class SessionRightPanel extends React.Component { // Unlike visual media, only one non-image attachment is supported const documents = rawDocuments.map( (message: { attachments: Array }) => { - const attachments = message.attachments || []; - const attachment = attachments[0]; + // this is to not fail if the attachment is invalid (could be a Long Attachment type which is not supported) + 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 { contentType: attachment.contentType, @@ -220,7 +226,7 @@ class SessionRightPanel extends React.Component { return { media, - documents, + documents: _.compact(documents), // remove null onItemClick, }; }