diff --git a/libtextsecure/message_receiver.js b/libtextsecure/message_receiver.js index ba88a42e3..aaadc8818 100644 --- a/libtextsecure/message_receiver.js +++ b/libtextsecure/message_receiver.js @@ -1095,20 +1095,16 @@ MessageReceiver.prototype.extend({ }, async handlePairingRequest(envelope, pairingRequest) { const valid = await this.validateAuthorisation(pairingRequest); - if (!valid) { - return this.removeFromCache(envelope); - } - await window.libloki.storage.savePairingAuthorisation(pairingRequest); - if (Whisper.events.isListenedTo('devicePairingRequestReceived')) { - Whisper.events.trigger( - 'devicePairingRequestReceived', - pairingRequest.secondaryDevicePubKey - ); - } else { - Whisper.events.trigger( - 'devicePairingRequestRejected', - pairingRequest.secondaryDevicePubKey - ); + if (valid) { + // Pairing dialog is open and is listening + if (Whisper.events.isListenedTo('devicePairingRequestReceived')) { + await window.libloki.storage.savePairingAuthorisation(pairingRequest); + Whisper.events.trigger( + 'devicePairingRequestReceived', + pairingRequest.secondaryDevicePubKey + ); + } + // Ignore requests if the dialog is closed } return this.removeFromCache(envelope); },