Delete right away if we already have the message

This commit is contained in:
Josh Perez 2020-07-27 14:15:32 -04:00 committed by Scott Nonnenberg
parent dfa846e4f3
commit 1ad2b175dc
10 changed files with 194 additions and 27 deletions

View file

@ -1111,7 +1111,7 @@
isErased() {
return Boolean(this.get('isErased'));
},
async eraseContents(additionalProperties = {}) {
async eraseContents(additionalProperties = {}, shouldPersist = true) {
if (this.get('isErased')) {
return;
}
@ -1139,9 +1139,11 @@
});
this.trigger('content-changed');
await window.Signal.Data.saveMessage(this.attributes, {
Message: Whisper.Message,
});
if (shouldPersist) {
await window.Signal.Data.saveMessage(this.attributes, {
Message: Whisper.Message,
});
}
},
unload() {
if (this.quotedMessage) {
@ -2583,7 +2585,9 @@
// Does this message have any pending, previously-received associated
// delete for everyone messages?
const deletes = Whisper.Deletes.forMessage(message);
deletes.forEach(del => Whisper.Deletes.onDelete(del, false));
deletes.forEach(del => {
window.Signal.Util.deleteForEveryone(message, del, false);
});
await window.Signal.Data.saveMessage(message.attributes, {
Message: Whisper.Message,
@ -2658,7 +2662,7 @@
}
},
async handleDeleteForEveryone(del) {
async handleDeleteForEveryone(del, shouldPersist = true) {
window.log.info('Handling DOE.', {
fromId: del.get('fromId'),
targetSentTimestamp: del.get('targetSentTimestamp'),
@ -2673,7 +2677,10 @@
Whisper.Notifications.remove(notificationForMessage);
// Erase the contents of this message
await this.eraseContents({ deletedForEveryone: true, reactions: [] });
await this.eraseContents(
{ deletedForEveryone: true, reactions: [] },
shouldPersist
);
// Update the conversation's last message in case this was the last message
this.getConversation().updateLastMessage();