mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
do not fail if a message has a list of empty attachment
This commit is contained in:
parent
f28dfe5a94
commit
4a58b2c9f6
1 changed files with 9 additions and 3 deletions
|
@ -174,8 +174,14 @@ class SessionRightPanel extends React.Component<Props, State> {
|
|||
// Unlike visual media, only one non-image attachment is supported
|
||||
const documents = rawDocuments.map(
|
||||
(message: { attachments: Array<any> }) => {
|
||||
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<Props, State> {
|
|||
|
||||
return {
|
||||
media,
|
||||
documents,
|
||||
documents: _.compact(documents), // remove null
|
||||
onItemClick,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue