You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/12 07:20:45 UTC

[51/52] [abbrv] fauxton commit: updated refs/heads/import-master to d11b90b

Fauxton: Improvements to xhr cancellations


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/be87767b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/be87767b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/be87767b

Branch: refs/heads/import-master
Commit: be87767b6819a82d0909efb8b334e8db1eefcd22
Parents: 3c17314
Author: Garren Smith <ga...@gmail.com>
Authored: Mon Feb 10 15:53:10 2014 +0200
Committer: Garren Smith <ga...@gmail.com>
Committed: Mon Feb 10 15:53:10 2014 +0200

----------------------------------------------------------------------
 app/core/base.js                          | 1 +
 app/core/couchdbSession.js                | 6 +++---
 app/core/routeObject.js                   | 4 +++-
 app/core/router.js                        | 6 +++---
 assets/js/plugins/backbone.fetch-cache.js | 8 ++++----
 5 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/be87767b/app/core/base.js
----------------------------------------------------------------------
diff --git a/app/core/base.js b/app/core/base.js
index 24b89cf..7cacf39 100644
--- a/app/core/base.js
+++ b/app/core/base.js
@@ -96,6 +96,7 @@ function(Backbone, LayoutManager, BackboneCache) {
 
       fetchPromise.progress(promise.resolveWith); // Fires when the cache hit happens
       fetchPromise.then(promise.resolveWith); // Fires after the AJAX call
+      promise.fail(fetchPromise.abort);
 
       return promise;
     }

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/be87767b/app/core/couchdbSession.js
----------------------------------------------------------------------
diff --git a/app/core/couchdbSession.js b/app/core/couchdbSession.js
index b70ddf3..c59a8fc 100644
--- a/app/core/couchdbSession.js
+++ b/app/core/couchdbSession.js
@@ -30,15 +30,15 @@ function (FauxtonAPI) {
       fetchUser: function (opt) {
         var that = this,
             options = opt || {},
-        currentUser = this.user(),
-        fetch = this.fetchOnce;
+            currentUser = this.user(),
+            fetch = _.bind(this.fetchOnce, this);
 
         if (options.forceFetch) {
           fetch = this.fetch;
           Backbone.fetchCache.clearItem(_.result(this.url));
         }
 
-        return this.fetch(opt).then(function () {
+        return fetch(opt).then(function () {
           var user = that.user();
 
           // Notify anyone listening on these events that either a user has changed

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/be87767b/app/core/routeObject.js
----------------------------------------------------------------------
diff --git a/app/core/routeObject.js b/app/core/routeObject.js
index f3b8672..9f1067f 100644
--- a/app/core/routeObject.js
+++ b/app/core/routeObject.js
@@ -223,6 +223,7 @@ function(FauxtonAPI, Backbone) {
       _.each(this.views, function (view, selector) {
         view.remove();
         delete this.views[selector];
+        view = null;
       }, this);
     },
 
@@ -230,6 +231,7 @@ function(FauxtonAPI, Backbone) {
       if (_.isEmpty(promise)) { return; }
 
       if (!_.isArray(promise)) {
+        if (!promise.abort && !promise.reject) {
         return this._promises.push(promise);
       }
 
@@ -250,7 +252,7 @@ function(FauxtonAPI, Backbone) {
           return promise.abort("Route change");
         } 
 
-        promise.reject();
+        promise.reject && promise.reject();
       }, this);
 
       this._promises = [];

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/be87767b/app/core/router.js
----------------------------------------------------------------------
diff --git a/app/core/router.js b/app/core/router.js
index cc1ca4f..bef4ced 100644
--- a/app/core/router.js
+++ b/app/core/router.js
@@ -59,13 +59,13 @@ function(FauxtonAPI, Auth, Backbone) {
 
           authPromise.then(function () {
             if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
-              if (that.activeRouteObject) {
-                that.activeRouteObject.cleanup();
-              }
+              that.activeRouteObject && that.activeRouteObject.cleanup();
+
               that.activeRouteObject = new RouteObject(route, masterLayout, args);
             }
 
             var routeObject = that.activeRouteObject;
+            routeObject.rejectPromises();
             routeObject.routeCallback(route, args);
             routeObject.renderWith(route, masterLayout, args);
           }, function () {

http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/be87767b/assets/js/plugins/backbone.fetch-cache.js
----------------------------------------------------------------------
diff --git a/assets/js/plugins/backbone.fetch-cache.js b/assets/js/plugins/backbone.fetch-cache.js
index c86a8b9..4aa7676 100644
--- a/assets/js/plugins/backbone.fetch-cache.js
+++ b/assets/js/plugins/backbone.fetch-cache.js
@@ -192,7 +192,7 @@
       }
 
       if (!opts.prefill) {
-        return deferred.promise();
+        return deferred;
       }
     }
 
@@ -206,7 +206,7 @@
       .fail( _.bind(deferred.reject, this, this) );
 
     // return a promise which provides the same methods as a jqXHR object
-    return deferred.promise();
+    return deferred;
   };
 
   // Override Model.prototype.sync and try to clear cache items if it looks
@@ -278,7 +278,7 @@
       }
 
       if (!opts.prefill) {
-        return deferred.promise();
+        return deferred;
       }
     }
 
@@ -292,7 +292,7 @@
       .fail( _.bind(deferred.reject, this, this) );
 
     // return a promise which provides the same methods as a jqXHR object
-    return deferred.promise();
+    return deferred;
   };
 
   // Prime the cache from localStorage on initialization