diff --git a/public_html/js/Presenters/ProgressPresenter.js b/public_html/js/Presenters/ProgressPresenter.js
index ff0b8306..d0a4cab7 100644
--- a/public_html/js/Presenters/ProgressPresenter.js
+++ b/public_html/js/Presenters/ProgressPresenter.js
@@ -12,10 +12,16 @@ App.Presenters.ProgressPresenter = function(nprogress) {
}
}
- function done() {
- nesting --;
+ function reset() {
+ nesting = 0;
+ }
- if (nesting === 0) {
+ function done() {
+ if (nesting) {
+ nesting --;
+ }
+
+ if (nesting <= 0) {
nprogress.done();
} else {
nprogress.inc();
@@ -25,6 +31,7 @@ App.Presenters.ProgressPresenter = function(nprogress) {
return {
start: start,
done: done,
+ reset: reset,
};
};
diff --git a/public_html/js/Promise.js b/public_html/js/Promise.js
index e211d38f..0cdb6d53 100644
--- a/public_html/js/Promise.js
+++ b/public_html/js/Promise.js
@@ -10,12 +10,23 @@ App.Promise = function(_, jQuery, progress) {
var promise = deferred.promise();
promise.promiseId = ++ promiseId;
+ progress.start();
callback(function() {
- deferred.resolve.apply(deferred, arguments);
- active = _.without(active, promise.promiseId);
+ try {
+ deferred.resolve.apply(deferred, arguments);
+ active = _.without(active, promise.promiseId);
+ progress.done();
+ } catch (e) {
+ progress.reset();
+ }
}, function() {
- deferred.reject.apply(deferred, arguments);
- active = _.without(active, promise.promiseId);
+ try {
+ deferred.reject.apply(deferred, arguments);
+ active = _.without(active, promise.promiseId);
+ progress.done();
+ } catch (e) {
+ progress.reset();
+ }
});
active.push(promise.promiseId);
@@ -30,7 +41,6 @@ App.Promise = function(_, jQuery, progress) {
}
function wait() {
- progress.start();
var promises = arguments;
var deferred = jQuery.Deferred();
return jQuery.when.apply(jQuery, promises)
@@ -38,8 +48,6 @@ App.Promise = function(_, jQuery, progress) {
return deferred.resolve.apply(deferred, arguments);
}).fail(function() {
return deferred.reject.apply(deferred, arguments);
- }).always(function() {
- progress.done();
});
}