From 3332cb240e0269de04f5d06608bf6f4e07bd9a28 Mon Sep 17 00:00:00 2001 From: Beaudan Brown Date: Thu, 29 Aug 2019 14:37:04 +1000 Subject: [PATCH] Add background event listener --- js/background.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/js/background.js b/js/background.js index a791a9ccc..c30a385d0 100644 --- a/js/background.js +++ b/js/background.js @@ -487,6 +487,28 @@ } }); + Whisper.events.on( + 'deletePublicMessage', + async ({ messageServerId, conversationId }) => { + const message = await window.Signal.Data.getMessageByServerId( + messageServerId, + conversationId, + { + Message: Whisper.Message, + } + ); + if (message) { + const conversation = ConversationController.get(conversationId); + if (conversation) { + conversation.removeMessage(message.id); + } + await window.Signal.Data.removeMessage(message.id, { + Message: Whisper.Message, + }); + } + } + ); + Whisper.events.on('setupAsNewDevice', () => { const { appView } = window.owsDesktopApp; if (appView) { @@ -1418,6 +1440,7 @@ let messageData = { source: data.source, sourceDevice: data.sourceDevice, + serverId: data.serverId, sent_at: data.timestamp, received_at: data.receivedAt || Date.now(), conversationId: data.source,