Ensure one listener and one event for 'secondaryDeviceRegistration'

pull/431/head
sachaaaaa 6 years ago
parent 632e35c8a5
commit 2754969b23

@ -126,16 +126,25 @@
const language = this.$('#mnemonic-display-language').val(); const language = this.$('#mnemonic-display-language').val();
this.showProfilePage(mnemonic, language); this.showProfilePage(mnemonic, language);
}, },
onSecondaryDeviceRegistered() {
// Ensure the left menu is updated
Whisper.events.trigger('userChanged', { isSecondaryDevice: true });
this.$el.trigger('openInbox');
},
async registerSecondaryDevice() { async registerSecondaryDevice() {
const mnemonic = this.$('#mnemonic-display').text(); const mnemonic = this.$('#mnemonic-display').text();
const language = this.$('#mnemonic-display-language').val(); const language = this.$('#mnemonic-display-language').val();
const primaryPubKey = this.$('#primary-pubkey').val(); const primaryPubKey = this.$('#primary-pubkey').val();
this.$('.standalone-secondary-device #error').hide(); this.$('.standalone-secondary-device #error').hide();
Whisper.events.on('secondaryDeviceRegistration', () => { // Ensure only one listener
// Ensure the left menu is updated Whisper.events.off(
Whisper.events.trigger('userChanged', { isSecondaryDevice: true }); 'secondaryDeviceRegistration',
this.$el.trigger('openInbox'); this.onSecondaryDeviceRegistered
}); );
Whisper.events.once(
'secondaryDeviceRegistration',
this.onSecondaryDeviceRegistered
);
clearTimeout(this.pairingTimeout); clearTimeout(this.pairingTimeout);
this.pairingTimeout = setTimeout(() => { this.pairingTimeout = setTimeout(() => {
this.$('.standalone-secondary-device #error').text( this.$('.standalone-secondary-device #error').text(

Loading…
Cancel
Save