@@ -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 ,
@@ -571,7 +570,7 @@ launchOnboarding = function(guidCreating) {
571570} ) ( ) ;
572571
573572pageConnectModal . on ( 'cancel' , ( ) => {
574- removeStartupRetry ( ) ;
573+ resetRetry ( ) ;
575574 app . getHeartbeatSocket ( ) . _socket . onclose = null ;
576575 app . getHeartbeatSocket ( ) . close ( ) ;
577576 pageConnectModal . remove ( ) ;
@@ -594,9 +593,10 @@ app.serverConnectModal.on('connected', () => {
594593} ) ;
595594
596595app . getHeartbeatSocket ( ) . on ( 'open' , function ( ) {
597- removeStartupRetry ( ) ;
596+ resetRetry ( ) ;
598597 pageConnectModal . remove ( ) ;
599- startUpLoadingModal . open ( ) ;
598+ //startUpLoadingModal.open();
599+ this . retryConnectionMsg && this . retryConnectionMsg . remove ( ) ;
600600
601601 if ( ! profileLoaded ) {
602602 // clear some flags so the heartbeat events will
@@ -609,21 +609,33 @@ app.getHeartbeatSocket().on('open', function() {
609609} ) ;
610610
611611app . getHeartbeatSocket ( ) . on ( 'close' , startUpRetry = function ( ) {
612- if (
613- Date . now ( ) - startTime < startUpConnectMaxTime &&
614- startUpConnectMaxRetries
612+ if ( starutUpConnectCurrentRetries
615613 ) {
616614 startUpRetry . timeout = setTimeout ( ( ) => {
617- startUpConnectMaxRetries -- ;
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 -- ;
618621 app . connectHeartbeatSocket ( ) ;
622+ if ( this . retryConnectionMsg ) {
623+ this . retryConnectionMsg . updateMessage ( retryMsg ) ;
624+ } else {
625+ this . retryConnectionMsg = app . statusBar . pushMessage ( retryMsg ) ;
626+ }
619627 } , startUpConnectRetryDelay ) ;
620628 } else {
629+ this . retryConnectionMsg && this . retryConnectionMsg . remove ( ) ;
621630 app . serverConnectModal . failConnection ( null , app . serverConfigs . getActive ( ) )
622631 . open ( ) ;
623632 }
624633} ) ;
625634
626- removeStartupRetry = function ( ) {
635+ resetRetry = function ( ) {
636+ starutUpConnectCurrentRetries = startUpConnectMaxRetries ;
637+ /* this code removed so the app will automatically reconnect when the internet connection is flaky */
638+ /*
627639 clearTimeout(startUpRetry.timeout);
628640 app.getHeartbeatSocket().off('close', startUpRetry);
629641 app.getHeartbeatSocket().on('close', () => {
@@ -638,6 +650,7 @@ removeStartupRetry = function() {
638650 app.serverConnectModal.open();
639651 }
640652 });
653+ */
641654} ;
642655
643656app . getHeartbeatSocket ( ) . on ( 'message' , function ( e ) {
0 commit comments