From 8eed6b62b9c014d90b144bf595b257c1b8bf8cc9 Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Tue, 9 Jun 2020 17:08:03 -0400 Subject: [PATCH] Wrap delivery receipt sends in conversation.queueJob --- js/background.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/js/background.js b/js/background.js index 73fb2d7af66..9cf2de5199b 100644 --- a/js/background.js +++ b/js/background.js @@ -32,26 +32,28 @@ const source = sources[i]; const timestamps = bySource[source].map(item => item.timestamp); - try { - const c = ConversationController.get(source); - const { wrap, sendOptions } = ConversationController.prepareForSend( - c.get('id') - ); - // eslint-disable-next-line no-await-in-loop - await wrap( - textsecure.messaging.sendDeliveryReceipt( - c.get('e164'), - c.get('uuid'), - timestamps, - sendOptions - ) - ); - } catch (error) { - window.log.error( - `Failed to send delivery receipt to ${source} for timestamps ${timestamps}:`, - error && error.stack ? error.stack : error - ); - } + const c = ConversationController.get(source); + c.queueJob(async () => { + try { + const { wrap, sendOptions } = ConversationController.prepareForSend( + c.get('id') + ); + // eslint-disable-next-line no-await-in-loop + await wrap( + textsecure.messaging.sendDeliveryReceipt( + c.get('e164'), + c.get('uuid'), + timestamps, + sendOptions + ) + ); + } catch (error) { + window.log.error( + `Failed to send delivery receipt to ${source} for timestamps ${timestamps}:`, + error && error.stack ? error.stack : error + ); + } + }); } }, });