Copy quoted message contents into quote on receipt
Also: - visually distinguish any reference we couldn't verify on receipt - show toast on quote click if we can't scroll to message - toast visuals redesigned to match rest of app
This commit is contained in:
parent
a247ffe5cf
commit
fedfbed304
15 changed files with 468 additions and 336 deletions
|
@ -973,7 +973,9 @@
|
|||
return event.confirm();
|
||||
}
|
||||
|
||||
const upgradedMessage = await upgradeMessageSchema(data.message);
|
||||
const withQuoteReference = await copyFromQuotedMessage(data.message);
|
||||
const upgradedMessage = await upgradeMessageSchema(withQuoteReference);
|
||||
|
||||
await ConversationController.getOrCreateAndWait(
|
||||
messageDescriptor.id,
|
||||
messageDescriptor.type
|
||||
|
@ -984,6 +986,80 @@
|
|||
};
|
||||
}
|
||||
|
||||
async function copyFromQuotedMessage(message) {
|
||||
const { quote } = message;
|
||||
if (!quote) {
|
||||
return message;
|
||||
}
|
||||
|
||||
const { attachments, id, author } = quote;
|
||||
const firstAttachment = attachments[0];
|
||||
|
||||
const collection = await window.Signal.Data.getMessagesBySentAt(id, {
|
||||
MessageCollection: Whisper.MessageCollection,
|
||||
});
|
||||
const queryMessage = collection.find(item => {
|
||||
const messageAuthor = item.getContact();
|
||||
|
||||
return messageAuthor && author === messageAuthor.id;
|
||||
});
|
||||
|
||||
if (!queryMessage) {
|
||||
quote.referencedMessageNotFound = true;
|
||||
return message;
|
||||
}
|
||||
|
||||
quote.text = queryMessage.get('body');
|
||||
if (firstAttachment) {
|
||||
firstAttachment.thumbnail = null;
|
||||
}
|
||||
|
||||
if (
|
||||
!firstAttachment ||
|
||||
(!window.Signal.Util.GoogleChrome.isImageTypeSupported(
|
||||
firstAttachment.contentType
|
||||
) &&
|
||||
!window.Signal.Util.GoogleChrome.isVideoTypeSupported(
|
||||
firstAttachment.contentType
|
||||
))
|
||||
) {
|
||||
return message;
|
||||
}
|
||||
|
||||
try {
|
||||
if (queryMessage.get('schemaVersion') < Message.CURRENT_SCHEMA_VERSION) {
|
||||
const upgradedMessage = await upgradeMessageSchema(
|
||||
queryMessage.attributes
|
||||
);
|
||||
queryMessage.set(upgradedMessage);
|
||||
await window.Signal.Data.saveMessage(upgradedMessage, {
|
||||
Message: Whisper.Message,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
window.log.error(
|
||||
'Problem upgrading message quoted message from database',
|
||||
Errors.toLogFormat(error)
|
||||
);
|
||||
return message;
|
||||
}
|
||||
|
||||
const queryAttachments = queryMessage.get('attachments') || [];
|
||||
|
||||
if (queryAttachments.length === 0) {
|
||||
return message;
|
||||
}
|
||||
|
||||
const queryFirst = queryAttachments[0];
|
||||
const { thumbnail } = queryFirst;
|
||||
|
||||
if (thumbnail && thumbnail.path) {
|
||||
firstAttachment.thumbnail = thumbnail;
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
// Received:
|
||||
async function handleMessageReceivedProfileUpdate({
|
||||
data,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue