You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by robertkowalski <gi...@git.apache.org> on 2015/10/07 15:54:55 UTC
[GitHub] couchdb-fauxton pull request: Improve db page error handling
Github user robertkowalski commented on a diff in the pull request:
https://github.com/apache/couchdb-fauxton/pull/549#discussion_r41392558
--- Diff: app/addons/databases/actions.js ---
@@ -26,20 +26,35 @@ function (app, FauxtonAPI, Stores, ActionTypes, Resources) {
this.setStartLoading();
FauxtonAPI.when(databases.fetch({ cache: false })).then(function () {
- FauxtonAPI.when(databases.paginated(page, perPage).map(function (database) {
- return database.status.fetchOnce();
- })).always(function () {
- //make this always so that even if a user is not allowed access to a database
- //they will still see a list of all databases
+ var numComplete = 0;
+ _.each(databases.paginated(page, perPage), function (db) {
+ db.status.fetchOnce().always(function () {
+ numComplete++;
+ if (numComplete < databases.paginated(page, perPage).length) {
+ return;
+ }
+ FauxtonAPI.dispatch({
+ type: ActionTypes.DATABASES_INIT,
+ options: {
+ collection: databases.paginated(page, perPage),
+ backboneCollection: databases,
+ page: page
+ }
+ });
+ });
+ });
+
+ // if there are no databases, publish the init message anyway
+ if (!databases.paginated(page, perPage).length) {
FauxtonAPI.dispatch({
type: ActionTypes.DATABASES_INIT,
options: {
- collection: databases.paginated(page, perPage),
+ collection: [],
backboneCollection: databases,
page: page
}
});
- }.bind(this));
+ }
}.bind(this));
},
--- End diff --
i don't understand this part of the diff
isn't it the same code as the map but written with an each and a counter that counts side effects? if so i would prefer the map back again, the counter thingy is a bit odd
to speed up the code you can also put the `if (!databases.paginated(page, perPage).length) {` above the other code and just return early
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---