From e479ee63324038a2447d85e6fc7c47150cb7c9e4 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Thu, 12 Nov 2020 12:19:34 +1100 Subject: [PATCH] saveError on message sending without connection on private chat --- js/models/conversations.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 3c9a657cb..0c1fcfed2 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -1211,12 +1211,20 @@ // We're offline! if (!textsecure.messaging) { - const errors = this.contactCollection.map(contact => { + let errors; + if (this.contactCollection.length) { + errors = this.contactCollection.map(contact => { + const error = new Error('Network is not available'); + error.name = 'SendMessageNetworkError'; + error.number = contact.id; + return error; + }); + } else { const error = new Error('Network is not available'); error.name = 'SendMessageNetworkError'; - error.number = contact.id; - return error; - }); + error.number = this.id; + errors = [error]; + } await message.saveErrors(errors); return null; }