From dda71cbea10ffff4426bfbbdfa900d3ddd4c0a68 Mon Sep 17 00:00:00 2001 From: sachaaaaa Date: Thu, 1 Nov 2018 17:07:07 +1100 Subject: [PATCH 1/4] always lock editor after sending friend request. unlock if error. --- libtextsecure/outgoing_message.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libtextsecure/outgoing_message.js b/libtextsecure/outgoing_message.js index ca1b82180..8a34a4910 100644 --- a/libtextsecure/outgoing_message.js +++ b/libtextsecure/outgoing_message.js @@ -296,6 +296,10 @@ OutgoingMessage.prototype = { this.numberCompleted(); }) .catch(error => { + // TODO(loki): handle http errors properly + // - retry later if 400 + // - ignore if 409 (conflict) means the hash already exists + throw error; if ( error instanceof Error && error.name === 'HTTPError' && @@ -409,6 +413,10 @@ OutgoingMessage.prototype = { } } + if (this.fallBackEncryption && conversation) { + conversation.onFriendRequestSent(); + } + if (attachPrekeys) { log.info('attaching prekeys to outgoing message'); this.message.preKeyBundleMessage = await libloki.getPreKeyBundleForNumber( @@ -417,12 +425,10 @@ OutgoingMessage.prototype = { } }) .then(this.reloadDevicesAndSend(number, true)) - .then(() => { + .catch(error => { if (this.fallBackEncryption && conversation) { - conversation.onFriendRequestSent(); + conversation.onFriendRequestTimedOut(); } - }) - .catch(error => { if (error.message === 'Identity key changed') { // eslint-disable-next-line no-param-reassign error = new textsecure.OutgoingIdentityKeyError( From 8d9fbdb3df4360fb800015926a77eb2e998b1998 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Mon, 5 Nov 2018 16:13:38 +1100 Subject: [PATCH 2/4] Fix create conversation appearing even if you already have a conversation with the contact. --- js/views/conversation_search_view.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/js/views/conversation_search_view.js b/js/views/conversation_search_view.js index 774500752..871b4d559 100644 --- a/js/views/conversation_search_view.js +++ b/js/views/conversation_search_view.js @@ -84,6 +84,11 @@ this.typeahead_view.collection.reset( this.typeahead.filter(isSearchable) ); + + // Check if the query is in the model list + // If it is then hide the new contact view + var modelExists = this.typeahead_view.collection.find(item => item.get('id') == query); + if (modelExists) this.new_contact_view.$el.hide(); }) ); /* eslint-enable more/no-then */ From 28f6992085eeedbc352dcd04de08529ee137ce62 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Mon, 5 Nov 2018 16:38:51 +1100 Subject: [PATCH 3/4] Replaced var with const. --- js/views/conversation_search_view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/views/conversation_search_view.js b/js/views/conversation_search_view.js index 871b4d559..98ba719c2 100644 --- a/js/views/conversation_search_view.js +++ b/js/views/conversation_search_view.js @@ -87,7 +87,7 @@ // Check if the query is in the model list // If it is then hide the new contact view - var modelExists = this.typeahead_view.collection.find(item => item.get('id') == query); + const modelExists = this.typeahead_view.collection.find(item => item.get('id') == query); if (modelExists) this.new_contact_view.$el.hide(); }) ); From 61d15fdd57e4c7de0d865e65c3753cf21b5afe0c Mon Sep 17 00:00:00 2001 From: Mikunj Date: Wed, 7 Nov 2018 13:20:52 +1100 Subject: [PATCH 4/4] Changed == to === --- js/views/conversation_search_view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/views/conversation_search_view.js b/js/views/conversation_search_view.js index 98ba719c2..3618585bd 100644 --- a/js/views/conversation_search_view.js +++ b/js/views/conversation_search_view.js @@ -87,7 +87,7 @@ // Check if the query is in the model list // If it is then hide the new contact view - const modelExists = this.typeahead_view.collection.find(item => item.get('id') == query); + const modelExists = this.typeahead_view.collection.find(item => item.get('id') === query); if (modelExists) this.new_contact_view.$el.hide(); }) );