summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarren Smith <garren.smith@gmail.com>2013-08-21 11:04:26 +0200
committerGarren Smith <garren.smith@gmail.com>2013-08-21 11:35:39 +0200
commitd3c2077131c18d0b109b30b7e5b8be41a4d1ac6d (patch)
tree7f4f21d63566320e983ced9b772bafde99b8c76c
parentfbd16d01a408bacd48b265f1ff1ff0de3ca58809 (diff)
downloadcouchdb-d3c2077131c18d0b109b30b7e5b8be41a4d1ac6d.tar.gz
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
-rw-r--r--src/fauxton/app/api.js18
-rw-r--r--src/fauxton/app/router.js5
2 files changed, 19 insertions, 4 deletions
diff --git a/src/fauxton/app/api.js b/src/fauxton/app/api.js
index 0a2351da4..5cf59a21a 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'));
},
diff --git a/src/fauxton/app/router.js b/src/fauxton/app/router.js
index c12d951ac..509cff446 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);
}