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

Commit f005d8f

Browse files
committed
some code clean-up
1 parent eef6065 commit f005d8f

File tree

3 files changed

+18
-523
lines changed

3 files changed

+18
-523
lines changed

js/AppNew.js

Lines changed: 0 additions & 250 deletions
This file was deleted.

js/main.js

Lines changed: 18 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,16 @@ var Polyglot = require('node-polyglot'),
5252
startUpConnectRetryDelay = 2 * 1000,
5353
startUpConnectMaxTime = 6 * 1000,
5454
startTime = Date.now(),
55+
startUpRetry,
5556
onActiveServerSync,
5657
extendPolyglot,
5758
newPageNavView,
5859
newSocketView,
5960
serverConnectModal,
6061
onboardingModal,
61-
startInitSequence,
62-
startLocalInitSequence,
63-
startRemoteInitSequence,
6462
launchOnboarding,
65-
launchServerConnect,
6663
setServerUrl,
67-
guidCreating,
68-
after401LoginRequest;
64+
guidCreating;
6965

7066
//put language in the window so all templates and models can reach it. It's especially important in formatting currency.
7167
//retrieve the stored value, since user is a blank model at this point
@@ -105,8 +101,6 @@ app.serverConfigs.fetch().done(() => {
105101
(setServerUrl = function() {
106102
var baseServerUrl = app.serverConfigs.getActive().getServerBaseUrl();
107103

108-
console.log(`mr bo jangles: ${baseServerUrl}`);
109-
110104
user.urlRoot = baseServerUrl + "/settings";
111105
user.set('serverUrl', baseServerUrl + '/');
112106
userProfile.urlRoot = baseServerUrl + "/profile";
@@ -350,26 +344,6 @@ var loadProfile = function(landingRoute, onboarded) {
350344
});
351345
};
352346

353-
$(document).ajaxError(function(event, jqxhr, settings, thrownError) {
354-
// if (jqxhr.status === 401) {
355-
// if (after401LoginRequest && after401LoginRequest.state() === 'pending') return;
356-
357-
// after401LoginRequest = app.login().done(function(data) {
358-
// var route = location.hash;
359-
360-
// if (data.success) {
361-
// // refresh the current route
362-
// Backbone.history.navigate('blah-blah-blah');
363-
// Backbone.history.navigate(route, { replace: true, trigger: true });
364-
// } else {
365-
// launchServerConnect();
366-
// }
367-
// }).fail(function() {
368-
// launchServerConnect();
369-
// });
370-
// }
371-
});
372-
373347
$(document).ajaxSend(function(e, jqXhr, settings) {
374348
// With this we could map ajax responses to the server config
375349
// that was active when they were initiated.
@@ -410,43 +384,30 @@ app.serverConnectModal.on('connected', (authenticated) => {
410384
});
411385

412386
app.getHeartbeatSocket().on('open', function(e) {
387+
app.getHeartbeatSocket().off('close', startUpRetry);
388+
413389
// clear some flags so the heartbeat events will
414390
// appropriatally loadProfile or launch onboarding
415391
guidCreating = null;
416392
loadProfileNeeded = true;
417393

418394
onboardingModal && onboardingModal.remove();
419-
420-
// if (profileLoaded) {
421-
// location.reload();
422-
// } else {
423-
// // clear some flags so the heartbeat events will
424-
// // appropriatally loadProfile or launch onboarding
425-
// guidCreating = null;
426-
// loadProfileNeeded = true;
427-
428-
// onboardingModal && onboardingModal.remove();
429-
// }
430395
});
431396

432-
app.getHeartbeatSocket().on('close', function(e) {
433-
// if (
434-
// Date.now() - startTime < startUpConnectMaxTime &&
435-
// startUpConnectMaxRetries
436-
// ) {
437-
// setTimeout(() => {
438-
// startUpConnectMaxRetries--;
439-
// app.connectHeartbeatSocket();
440-
// }, startUpConnectRetryDelay);
441-
// } else {
442-
// launchServerConnect();
443-
// }
444-
445-
// launchServerConnect();
446-
447-
app.serverConnectModal.failConnection(null, app.serverConfigs.getActive())
448-
.open();
449-
});
397+
app.getHeartbeatSocket().on('close', (startUpRetry = function(e) {
398+
if (
399+
Date.now() - startTime < startUpConnectMaxTime &&
400+
startUpConnectMaxRetries
401+
) {
402+
setTimeout(() => {
403+
startUpConnectMaxRetries--;
404+
app.connectHeartbeatSocket();
405+
}, startUpConnectRetryDelay);
406+
} else {
407+
app.serverConnectModal.failConnection(null, app.serverConfigs.getActive())
408+
.open();
409+
}
410+
}));
450411

451412
app.getHeartbeatSocket().on('message', function(e) {
452413
if (e.jsonData && e.jsonData.status) {

0 commit comments

Comments
 (0)