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

Commit 9540848

Browse files
committed
Code cleanup.
- change statusbar to update the message with a number of tries count. - remove commented out code - remove console logs - change to use startUpConnectCurrentRetries so startUpMaxRetries can be used to reset the count
1 parent 8d8ec23 commit 9540848

File tree

2 files changed

+22
-30
lines changed

2 files changed

+22
-30
lines changed

js/languages/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@
544544
"badSMTPAuthentication": "The username/password combination used failed.",
545545
"goodSMTPAuthentication": "You have successfully connected to the SMTP server.",
546546
"tagIsTooLongHeadline": "The tag is too long",
547-
"tagIsTooLongBody": "Tags cannot be more than %{smart_count} character long. |||| Tags cannot be more than %{smart_count} characters long."
547+
"tagIsTooLongBody": "Tags cannot be more than %{smart_count} character long. |||| Tags cannot be more than %{smart_count} characters long.",
548+
"retryingConnection": "The connection to your node was lost. Retrying connection attempt %{attempt} of %{total}."
548549
},
549550
"pageConnectingMessages": {
550551
"listingConnect": "Connecting to listing ${listing}",

js/start.js

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,11 @@ var Polyglot = require('node-polyglot'),
5454
PageConnectModal = require('./views/pageConnectModal'),
5555
Dialog = require('./views/dialog.js'),
5656
loadProfileNeeded = true,
57-
startUpConnectMaxRetries = 4,
58-
startUpConnectRetryDelay = 2 * 1000,
59-
//startUpConnectMaxTime = 10 * 1000,
60-
//startTime = Date.now(),
57+
startUpConnectMaxRetries = 5,
58+
starutUpConnectCurrentRetries = startUpConnectMaxRetries,
59+
startUpConnectRetryDelay = 3 * 1000,
6160
startUpRetry,
62-
removeStartupRetry,
61+
resetRetry,
6362
onActiveServerSync,
6463
newPageNavView,
6564
newSocketView,
@@ -527,7 +526,6 @@ $(document).ajaxSend(function(e, jqXhr) {
527526
});
528527

529528
$(document).ajaxError(function(event, jqxhr) {
530-
console.log("ajax error");
531529
if (jqxhr.status === 401 && jqxhr.serverConfig.id === app.serverConfigs.getActive().id) {
532530
app.serverConnectModal.failConnection('failed-auth', jqxhr.serverConfig)
533531
.open();
@@ -572,8 +570,7 @@ launchOnboarding = function(guidCreating) {
572570
})();
573571

574572
pageConnectModal.on('cancel', () => {
575-
console.log("page connect modal on cancel");
576-
removeStartupRetry();
573+
resetRetry();
577574
app.getHeartbeatSocket()._socket.onclose = null;
578575
app.getHeartbeatSocket().close();
579576
pageConnectModal.remove();
@@ -596,10 +593,9 @@ app.serverConnectModal.on('connected', () => {
596593
});
597594

598595
app.getHeartbeatSocket().on('open', function() {
599-
removeStartupRetry();
596+
resetRetry();
600597
pageConnectModal.remove();
601598
//startUpLoadingModal.open();
602-
console.log("heartbeat open");
603599
this.retryConnectionMsg && this.retryConnectionMsg.remove();
604600

605601
if (!profileLoaded) {
@@ -613,44 +609,39 @@ app.getHeartbeatSocket().on('open', function() {
613609
});
614610

615611
app.getHeartbeatSocket().on('close', startUpRetry = function() {
616-
console.log("heartbeat closed starupRetry");
617-
console.log(startUpConnectMaxRetries);
618-
/*
619-
if (
620-
Date.now() - startTime < startUpConnectMaxTime &&
621-
startUpConnectMaxRetries
622-
*/
623-
if (startUpConnectMaxRetries
612+
if (starutUpConnectCurrentRetries
624613
) {
625614
startUpRetry.timeout = setTimeout(() => {
626-
console.log("retry connection");
627-
startUpConnectMaxRetries--;
628-
app.connectHeartbeatSocket();
629-
this.retryConnectionMsg = this.retryConnectionMsg || app.statusBar.pushMessage({
615+
var retryMsg = {
630616
type: 'warning',
631-
msg: '<i>' + window.polyglot.t('retryingConnection') + '</i>',
617+
msg: '<i>' + window.polyglot.t('errorMessages.retryingConnection', {attempt: startUpConnectMaxRetries - starutUpConnectCurrentRetries +1, total: startUpConnectMaxRetries}) + '</i>',
632618
duration: false
633-
});
619+
};
620+
starutUpConnectCurrentRetries--;
621+
app.connectHeartbeatSocket();
622+
if (this.retryConnectionMsg) {
623+
this.retryConnectionMsg.updateMessage(retryMsg);
624+
} else {
625+
this.retryConnectionMsg = app.statusBar.pushMessage(retryMsg);
626+
}
634627
}, startUpConnectRetryDelay);
635628
} else {
636-
console.log("connect retries exceeded");
637629
this.retryConnectionMsg && this.retryConnectionMsg.remove();
638630
app.serverConnectModal.failConnection(null, app.serverConfigs.getActive())
639631
.open();
640632
}
641633
});
642634

643-
removeStartupRetry = function() {
644-
startUpConnectMaxRetries = 4;
635+
resetRetry = function() {
636+
starutUpConnectCurrentRetries = startUpConnectMaxRetries;
637+
/* this code removed so the app will automatically reconnect when the internet connection is flaky */
645638
/*
646639
clearTimeout(startUpRetry.timeout);
647640
app.getHeartbeatSocket().off('close', startUpRetry);
648641
app.getHeartbeatSocket().on('close', () => {
649-
console.log("removeStartupRetry close")
650642
app.serverConnectModal.failConnection(null, app.serverConfigs.getActive());
651643
652644
if (app.serverConnectModal.getConnectAttempt()) {
653-
console.log("get connect attempt")
654645
app.serverConnectModal.getConnectAttempt()
655646
.fail(() => {
656647
app.serverConnectModal.open();

0 commit comments

Comments
 (0)