Use online event listener to reconnect more smrtly
No need to retry if we know we're offline. // FREEBIE
This commit is contained in:
parent
37998e261d
commit
6f94888659
1 changed files with 7 additions and 1 deletions
|
@ -47,6 +47,7 @@
|
|||
}
|
||||
|
||||
function init() {
|
||||
window.removeEventListener('online', init);
|
||||
if (!textsecure.registration.isDone()) { return; }
|
||||
|
||||
// initialize the socket and start listening for messages
|
||||
|
@ -124,7 +125,12 @@
|
|||
}
|
||||
|
||||
if (e.name === 'HTTPError' && e.code == -1) {
|
||||
setTimeout(init, 60000);
|
||||
// Failed to connect to server
|
||||
if (navigator.onLine) {
|
||||
setTimeout(init, 60000);
|
||||
} else {
|
||||
window.addEventListener('online', init);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue