Reconnect provisioning socket
If the provisioning socket closes, reconnect and generate a new qr code. Fixes #371 // FREEBIE
This commit is contained in:
parent
47befdbf61
commit
9b12d8a978
3 changed files with 36 additions and 28 deletions
|
@ -61,34 +61,40 @@
|
|||
});
|
||||
|
||||
$(function() {
|
||||
$('#init-setup').show().addClass('in');
|
||||
$('#status').text("Connecting...");
|
||||
|
||||
var accountManager = new bg.getAccountManager();
|
||||
accountManager.registerSecondDevice(setProvisioningUrl, confirmNumber, incrementCounter).then(function() {
|
||||
var launch = function() {
|
||||
bg.openInbox();
|
||||
bg.removeEventListener('textsecure:contactsync', launch);
|
||||
clearTimeout(timeout);
|
||||
window.close();
|
||||
};
|
||||
var timeout = setTimeout(launch, 60000);
|
||||
bg.addEventListener('textsecure:contactsync', launch);
|
||||
$('.progress-dialog .status').text('Syncing groups and contacts');
|
||||
$('.progress-dialog .bar').addClass('progress-bar-striped active');
|
||||
|
||||
}).catch(function(e) {
|
||||
if (e.name === 'HTTPError' && e.code == 411) {
|
||||
$('.progress-dialog').hide();
|
||||
$('.error-dialog').show();
|
||||
$('.error-dialog .ok').click(function(e) {
|
||||
chrome.runtime.reload();
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
var init = function() {
|
||||
$('#init-setup').show().addClass('in');
|
||||
$('#qr').html('');
|
||||
$('#status').text("Connecting...");
|
||||
|
||||
accountManager.registerSecondDevice(setProvisioningUrl, confirmNumber, incrementCounter).then(function() {
|
||||
var launch = function() {
|
||||
bg.openInbox();
|
||||
bg.removeEventListener('textsecure:contactsync', launch);
|
||||
clearTimeout(timeout);
|
||||
window.close();
|
||||
};
|
||||
var timeout = setTimeout(launch, 60000);
|
||||
bg.addEventListener('textsecure:contactsync', launch);
|
||||
$('.progress-dialog .status').text('Syncing groups and contacts');
|
||||
$('.progress-dialog .bar').addClass('progress-bar-striped active');
|
||||
}).catch(function(e) {
|
||||
if (e.message === 'websocket closed') {
|
||||
init();
|
||||
} else if (e.name === 'HTTPError' && e.code == 411) {
|
||||
$('.progress-dialog').hide();
|
||||
$('.error-dialog').show();
|
||||
$('.error-dialog .ok').click(function(e) {
|
||||
chrome.runtime.reload();
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
};
|
||||
init();
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue