Commit c95073a3 authored by Robert Knight's avatar Robert Knight

Move several variables closer to where they are first used

This makes it more obvious which part of the method the variables are
relevant for.
parent ac133ff1
...@@ -170,29 +170,26 @@ function groups( ...@@ -170,29 +170,26 @@ function groups(
if (isSidebar) { if (isSidebar) {
uri = await getDocumentUriForGroupSearch(); uri = await getDocumentUriForGroupSearch();
} }
const directLinkedGroupId = store.getState().directLinkedGroupId; documentUri = uri;
const directLinkedAnnId = store.getState().directLinkedAnnotationId;
const params = {
expand: ['organization', 'scopes'],
};
let directLinkedAnnotationGroupId = null;
// Step 2: Concurrently fetch the groups the user is a member of, // Step 2: Concurrently fetch the groups the user is a member of,
// the groups associated with the current document and the annotation // the groups associated with the current document and the annotation
// or group that was direct-linked (if any). // or group that was direct-linked (if any).
const params = {
expand: ['organization', 'scopes'],
};
if (authority) { if (authority) {
params.authority = authority; params.authority = authority;
} }
if (uri) { if (uri) {
params.document_uri = uri; params.document_uri = uri;
} }
documentUri = uri;
// If there is a direct-linked annotation, fetch the annotation to see // If there is a direct-linked annotation, fetch the annotation to see
// if there needs to be a second API request to fetch its group since // if there needs to be a second API request to fetch its group since
// the group may not be in the results returned by group.list, // the group may not be in the results returned by group.list,
// profile.groups, or the direct-linked group. // profile.groups, or the direct-linked group.
const directLinkedAnnId = store.getState().directLinkedAnnotationId;
let directLinkedAnnApi = null; let directLinkedAnnApi = null;
if (directLinkedAnnId) { if (directLinkedAnnId) {
directLinkedAnnApi = api.annotation directLinkedAnnApi = api.annotation
...@@ -206,6 +203,7 @@ function groups( ...@@ -206,6 +203,7 @@ function groups(
// If there is a direct-linked group, add an API request to get that // If there is a direct-linked group, add an API request to get that
// particular group since it may not be in the results returned by // particular group since it may not be in the results returned by
// group.list or profile.groups. // group.list or profile.groups.
const directLinkedGroupId = store.getState().directLinkedGroupId;
let directLinkedGroupApi = null; let directLinkedGroupApi = null;
if (directLinkedGroupId) { if (directLinkedGroupId) {
directLinkedGroupApi = fetchGroup({ directLinkedGroupApi = fetchGroup({
...@@ -250,6 +248,7 @@ function groups( ...@@ -250,6 +248,7 @@ function groups(
// If there's a direct-linked annotation it may require an extra API call // If there's a direct-linked annotation it may require an extra API call
// to fetch its group. // to fetch its group.
let directLinkedAnnotationGroupId = null;
if (directLinkedAnn) { if (directLinkedAnn) {
// Set the directLinkedAnnotationGroupId to be used later in // Set the directLinkedAnnotationGroupId to be used later in
// the filterGroups method. // the filterGroups method.
...@@ -271,6 +270,7 @@ function groups( ...@@ -271,6 +270,7 @@ function groups(
} }
} }
} }
// Step 4. Combine all the groups into a single list and set additional // Step 4. Combine all the groups into a single list and set additional
// metadata on them that will be used elsewhere in the app. // metadata on them that will be used elsewhere in the app.
const isLoggedIn = token !== null; const isLoggedIn = token !== null;
......
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