Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/549#discussion_r42350418
  
    --- 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 --
    
    ah that makes sense now!
    
    +1 after changing to early return and putting the description into the 
commit msg, in case someone wonders by reading the code in 1 year :)


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to