@@ -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
574572pageConnectModal . 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
598595app . 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
615611app . 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