couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [15/50] [abbrv] git commit: updated refs/heads/1867-feature-plugins to 8aad450
Date Mon, 09 Sep 2013 09:53:35 GMT
Fauxton: fix establish and error notification issue
I've implemented a clean of an old route object's views as it seemed
that if an error occurs on the establish of a route object not all
the views were getting garbage collected.

fixes #COUCHDB-1873


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

Branch: refs/heads/1867-feature-plugins
Commit: 1cf161285555a0d7f7d2a5a64e398dd9d071d710
Parents: 5962904
Author: Garren Smith <garren.smith@gmail.com>
Authored: Wed Aug 21 11:04:26 2013 +0200
Committer: Jan Lehnardt <jan@apache.org>
Committed: Mon Sep 9 11:16:43 2013 +0200

----------------------------------------------------------------------
 src/fauxton/app/api.js    | 18 +++++++++++++++---
 src/fauxton/app/router.js |  5 ++++-
 2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/1cf16128/src/fauxton/app/api.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 0a2351d..5cf59a2 100644
--- a/src/fauxton/app/api.js
+++ b/src/fauxton/app/api.js
@@ -295,7 +295,7 @@ function(app, Fauxton) {
          $('.spinner').append(routeObjectSpinner.el);
        }
 
-      FauxtonAPI.when(this.establish()).done(function(resp) {
+      FauxtonAPI.when(this.establish()).then(function(resp) {
         _.each(routeObject.getViews(), function(view, selector) {
           if(view.hasRendered) { return; }
 
@@ -336,7 +336,7 @@ function(app, Fauxton) {
               };
 
               FauxtonAPI.addNotification({
-                msg: 'An Error occurred ' + resp,
+                msg: 'An Error occurred ' + resp.responseText,
                 type: 'error' 
               });
               masterLayout.renderView(selector);
@@ -351,7 +351,12 @@ function(app, Fauxton) {
             }
           });
         });
-      }.bind(this));
+      }.bind(this), function (resp) {
+          FauxtonAPI.addNotification({
+                msg: 'An Error occurred ' + resp.responseText,
+                type: 'error' 
+          });
+      });
 
       if (this.get('apiUrl')) masterLayout.apiBar.update(this.get('apiUrl'));
 
@@ -394,6 +399,13 @@ function(app, Fauxton) {
       return this.views;
     },
 
+    removeViews: function () {
+      _.each(this.views, function (view, selector) {
+        view.remove();
+        delete this.views[selector];
+      }, this);
+    },
+
     getRouteUrls: function () {
       return _.keys(this.get('routes'));
     },

http://git-wip-us.apache.org/repos/asf/couchdb/blob/1cf16128/src/fauxton/app/router.js
----------------------------------------------------------------------
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index c12d951..509cff4 100644
--- a/src/fauxton/app/router.js
+++ b/src/fauxton/app/router.js
@@ -51,7 +51,7 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents
     routes: {},
 
     addModuleRouteObject: function(RouteObject) {
-      var that = this; //change that to that
+      var that = this;
       var masterLayout = this.masterLayout,
       routeUrls = RouteObject.prototype.getRouteUrls();
 
@@ -63,6 +63,9 @@ function(req, app, Initialize, FauxtonAPI, Fauxton, Layout, Databases, Documents
 
           authPromise.then(function () {
             if (!that.activeRouteObject || !that.activeRouteObject.hasRoute(route)) {
+              if (that.activeRouteObject) {
+                that.activeRouteObject.removeViews();
+              }
               that.activeRouteObject = new RouteObject(route, masterLayout, args);
             }
 


Mime
View raw message