Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit cb5f8e7

Browse files
authored
Merge pull request #1792 from OpenBazaar/removeAutoReconnect
Removes the auto reconnect code
2 parents edb8efa + 807c541 commit cb5f8e7

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

js/start.js

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ var Polyglot = require('node-polyglot'),
5454
PageConnectModal = require('./views/pageConnectModal'),
5555
Dialog = require('./views/dialog.js'),
5656
loadProfileNeeded = true,
57-
startUpConnectMaxRetries = 5,
58-
starutUpConnectCurrentRetries = startUpConnectMaxRetries,
59-
startUpConnectRetryDelay = 3 * 1000,
57+
startUpConnectMaxRetries = 2,
58+
startUpConnectRetryDelay = 2 * 1000,
59+
startUpConnectMaxTime = 6 * 1000,
60+
startTime = Date.now(),
6061
startUpRetry,
61-
resetRetry,
62+
removeStartupRetry,
6263
onActiveServerSync,
6364
newPageNavView,
6465
newSocketView,
@@ -570,7 +571,7 @@ launchOnboarding = function(guidCreating) {
570571
})();
571572

572573
pageConnectModal.on('cancel', () => {
573-
resetRetry();
574+
removeStartupRetry();
574575
app.getHeartbeatSocket()._socket.onclose = null;
575576
app.getHeartbeatSocket().close();
576577
pageConnectModal.remove();
@@ -593,10 +594,9 @@ app.serverConnectModal.on('connected', () => {
593594
});
594595

595596
app.getHeartbeatSocket().on('open', function() {
596-
resetRetry();
597+
removeStartupRetry();
597598
pageConnectModal.remove();
598-
//startUpLoadingModal.open();
599-
this.retryConnectionMsg && this.retryConnectionMsg.remove();
599+
startUpLoadingModal.open();
600600

601601
if (!profileLoaded) {
602602
// clear some flags so the heartbeat events will
@@ -609,33 +609,21 @@ app.getHeartbeatSocket().on('open', function() {
609609
});
610610

611611
app.getHeartbeatSocket().on('close', startUpRetry = function() {
612-
if (starutUpConnectCurrentRetries
612+
if (
613+
Date.now() - startTime < startUpConnectMaxTime &&
614+
startUpConnectMaxRetries
613615
) {
614616
startUpRetry.timeout = setTimeout(() => {
615-
var retryMsg = {
616-
type: 'warning',
617-
msg: '<i>' + window.polyglot.t('errorMessages.retryingConnection', {attempt: startUpConnectMaxRetries - starutUpConnectCurrentRetries +1, total: startUpConnectMaxRetries}) + '</i>',
618-
duration: false
619-
};
620-
starutUpConnectCurrentRetries--;
617+
startUpConnectMaxRetries--;
621618
app.connectHeartbeatSocket();
622-
if (this.retryConnectionMsg) {
623-
this.retryConnectionMsg.updateMessage(retryMsg);
624-
} else {
625-
this.retryConnectionMsg = app.statusBar.pushMessage(retryMsg);
626-
}
627619
}, startUpConnectRetryDelay);
628620
} else {
629-
this.retryConnectionMsg && this.retryConnectionMsg.remove();
630621
app.serverConnectModal.failConnection(null, app.serverConfigs.getActive())
631622
.open();
632623
}
633624
});
634625

635-
resetRetry = function() {
636-
starutUpConnectCurrentRetries = startUpConnectMaxRetries;
637-
/* this code removed so the app will automatically reconnect when the internet connection is flaky */
638-
/*
626+
removeStartupRetry = function() {
639627
clearTimeout(startUpRetry.timeout);
640628
app.getHeartbeatSocket().off('close', startUpRetry);
641629
app.getHeartbeatSocket().on('close', () => {
@@ -650,7 +638,6 @@ resetRetry = function() {
650638
app.serverConnectModal.open();
651639
}
652640
});
653-
*/
654641
};
655642

656643
app.getHeartbeatSocket().on('message', function(e) {

0 commit comments

Comments
 (0)