diff --git a/background.html b/background.html index c7f3cdf5f..1f6db1eb1 100644 --- a/background.html +++ b/background.html @@ -681,6 +681,7 @@
+ diff --git a/js/views/standalone_registration_view.js b/js/views/standalone_registration_view.js index 8ce1f713c..6b91528d8 100644 --- a/js/views/standalone_registration_view.js +++ b/js/views/standalone_registration_view.js @@ -76,6 +76,7 @@ 'click #register': 'registerWithoutMnemonic', 'click #register-mnemonic': 'registerWithMnemonic', 'click #register-secondary-device': 'registerSecondaryDevice', + 'click #cancel-secondary-device': 'cancelSecondaryDevice', 'click #back-button': 'onBack', 'click #save-button': 'onSaveProfile', 'change #mnemonic': 'onChangeMnemonic', @@ -165,6 +166,18 @@ await window.ConversationController.load(); Whisper.RotateSignedPreKeyListener.stop(Whisper.events); }, + async cancelSecondaryDevice() { + Whisper.events.off( + 'secondaryDeviceRegistration', + this.onSecondaryDeviceRegistered + ); + this.$('#register-secondary-device') + .removeAttr('disabled') + .text('Link'); + this.$('#cancel-secondary-device').hide(); + this.$('.standalone-secondary-device #pubkey').text(''); + await this.resetRegistration(); + }, async registerSecondaryDevice() { if (textsecure.storage.get('secondaryDeviceStatus') === 'ongoing') { return; @@ -174,6 +187,7 @@ this.$('#register-secondary-device') .attr('disabled', 'disabled') .text('Sending...'); + this.$('#cancel-secondary-device').show(); const mnemonic = this.$('#mnemonic-display').text(); const language = this.$('#mnemonic-display-language').val(); const primaryPubKey = this.$('#primary-pubkey').val(); @@ -187,10 +201,7 @@ 'secondaryDeviceRegistration', this.onSecondaryDeviceRegistered ); - clearInterval(this.pairingInterval); - let countDown = 60; const onError = async error => { - clearInterval(this.pairingInterval); this.$('.standalone-secondary-device #error') .text(error) .show(); @@ -198,18 +209,7 @@ this.$('#register-secondary-device') .removeAttr('disabled') .text('Link'); - }; - const countDownCallBack = () => { - if (countDown > 0) { - this.$('#register-secondary-device').text( - `Waiting for Primary Device... (${countDown})` - ); - countDown -= 1; - return; - } - onError( - 'The primary device has not responded within 1 minute. Ensure that you accept the pairing on the primary device.' - ); + this.$('#cancel-secondary-device').hide(); }; const c = new Whisper.Conversation({ id: primaryPubKey, @@ -227,8 +227,6 @@ null ); await this.accountManager.requestPairing(primaryPubKey); - countDownCallBack(); - this.pairingInterval = setInterval(countDownCallBack, 1000); const pubkey = textsecure.storage.user.getNumber(); const words = window.mnemonic .mn_encode(pubkey.slice(2), 'english')