Commit f05b1b05 authored by Robert Knight's avatar Robert Knight

Use async/await to simplify the first part of the load() method

parent 06209ef5
......@@ -163,10 +163,12 @@ function groups(
*
* @return {Promise<Group[]>}
*/
function load() {
let uri = Promise.resolve(null);
async function load() {
// Step 1: Get the URI of the active document, so we can fetch groups
// associated with that document.
let uri = null;
if (isSidebar) {
uri = getDocumentUriForGroupSearch();
uri = await getDocumentUriForGroupSearch();
}
const directLinkedGroupId = store.getState().directLinkedGroupId;
const directLinkedAnnId = store.getState().directLinkedAnnotationId;
......@@ -176,10 +178,6 @@ function groups(
let directLinkedAnnotationGroupId = null;
// Step 1: Get the URI of the active document, so we can fetch groups
// associated with that document.
return uri
.then(uri => {
// Step 2: Concurrently fetch the groups the user is a member of,
// the groups associated with the current document and the annotation
// or group that was direct-linked (if any).
......@@ -235,8 +233,7 @@ function groups(
});
}
groupApiRequests = groupApiRequests.concat(directLinkedGroupApi);
return Promise.all(groupApiRequests);
})
return Promise.all(groupApiRequests)
.then(
([
myGroups,
......
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