Handle attachment load failure for quoted message

This commit is contained in:
Scott Nonnenberg 2018-04-16 12:17:13 -07:00
parent f1ff040842
commit 000dc3a159
No known key found for this signature in database
GPG key ID: 5F82280C35134661

View file

@ -1069,7 +1069,7 @@
return messages.reduce((acc, message) => { return messages.reduce((acc, message) => {
const { source, sent_at: sentAt } = message.attributes; const { source, sent_at: sentAt } = message.attributes;
// Checking for notification messages without a sender // Checking for notification messages (safety number change, timer change)
if (!source && message.isIncoming()) { if (!source && message.isIncoming()) {
return acc; return acc;
} }
@ -1112,19 +1112,27 @@
} }
const queryFirst = queryAttachments[0]; const queryFirst = queryAttachments[0];
try {
queryMessage.attachments[0] = await loadAttachmentData(queryFirst); queryMessage.attachments[0] = await loadAttachmentData(queryFirst);
// Note: it would be nice to take the full-size image and downsample it into // Note: it would be nice to take the full-size image and downsample it into
// a true thumbnail here. // a true thumbnail here.
queryMessage.updateImageUrl(); queryMessage.updateImageUrl();
// We need to differentiate between messages we load from database and those already // We need to differentiate between messages we load from database and those
// in memory. More cleanup needs to happen on messages from the database because // already in memory. More cleanup needs to happen on messages from the database
// they aren't tracked any other way. // because they aren't tracked any other way.
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
message.quotedMessageFromDatabase = queryMessage; message.quotedMessageFromDatabase = queryMessage;
return true; return true;
} catch (error) {
console.log(
'Problem loading attachment data for quoted message from database',
error && error.stack ? error.stack : error
);
return false;
}
}, },
async loadQuotedMessage(message, quotedMessage) { async loadQuotedMessage(message, quotedMessage) {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
@ -1145,6 +1153,7 @@
return; return;
} }
try {
const queryFirst = quotedAttachments[0]; const queryFirst = quotedAttachments[0];
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
quotedMessage.attributes.attachments[0] = await loadAttachmentData(queryFirst); quotedMessage.attributes.attachments[0] = await loadAttachmentData(queryFirst);
@ -1152,6 +1161,12 @@
// Note: it would be nice to take the full-size image and downsample it into // Note: it would be nice to take the full-size image and downsample it into
// a true thumbnail here. // a true thumbnail here.
quotedMessage.updateImageUrl(); quotedMessage.updateImageUrl();
} catch (error) {
console.log(
'Problem loading attachment data for quoted message',
error && error.stack ? error.stack : error
);
}
}, },
async loadQuoteThumbnail(message) { async loadQuoteThumbnail(message) {
const { quote } = message.attributes; const { quote } = message.attributes;