Commit a2da80d6 authored by Robert Knight's avatar Robert Knight

Use Promise chaining to remove a layer of nesting in `groups#load`

parent 3d09d3f6
...@@ -168,12 +168,13 @@ function groups( ...@@ -168,12 +168,13 @@ function groups(
} }
const directLinkedGroupId = store.getState().directLinkedGroupId; const directLinkedGroupId = store.getState().directLinkedGroupId;
const directLinkedAnnId = store.getState().directLinkedAnnotationId; const directLinkedAnnId = store.getState().directLinkedAnnotationId;
let directLinkedAnnotationGroupId = null;
return uri
.then(uri => {
const params = { const params = {
expand: ['organization', 'scopes'], expand: ['organization', 'scopes'],
}; };
let directLinkedAnnotationGroupId = null;
return uri
.then(uri => {
if (authority) { if (authority) {
params.authority = authority; params.authority = authority;
} }
...@@ -225,8 +226,9 @@ function groups( ...@@ -225,8 +226,9 @@ function groups(
}); });
} }
groupApiRequests = groupApiRequests.concat(selectedGroupApi); groupApiRequests = groupApiRequests.concat(selectedGroupApi);
return Promise.all(groupApiRequests).then( return Promise.all(groupApiRequests);
([myGroups, featuredGroups, token, selectedAnn, selectedGroup]) => { })
.then(([myGroups, featuredGroups, token, selectedAnn, selectedGroup]) => {
// If there is a direct-linked group, add it to the featured groups list. // If there is a direct-linked group, add it to the featured groups list.
const allFeaturedGroups = const allFeaturedGroups =
selectedGroup !== null && selectedGroup !== null &&
...@@ -271,8 +273,6 @@ function groups( ...@@ -271,8 +273,6 @@ function groups(
} }
// If there is no direct-linked annotation, return the list of groups without it. // If there is no direct-linked annotation, return the list of groups without it.
return [myGroups, allFeaturedGroups, documentUri, token]; return [myGroups, allFeaturedGroups, documentUri, token];
}
);
}) })
.then(([myGroups, featuredGroups, documentUri, token]) => { .then(([myGroups, featuredGroups, documentUri, token]) => {
const groups = combineGroups(myGroups, featuredGroups, documentUri); const groups = combineGroups(myGroups, featuredGroups, documentUri);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment