Merge pull request #541 from sachaaaaa/no_secondary_timeout

[multi-device] No secondary timeout
pull/548/head
sachaaaaa 6 years ago committed by GitHub
commit b73e6035c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -681,6 +681,7 @@
<div id='pubkey' class='collapse'></div>
<div id='error' class='collapse'></div>
<button type='button' class='button' id='register-secondary-device'>Link</button>
<button type='button' class='button' id='cancel-secondary-device' style="display: none;">Cancel</button>
</div>
</div>

@ -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')

Loading…
Cancel
Save