Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent multiple calls to concept set list when loading cohort editor #2888

Merged
merged 3 commits into from
Oct 24, 2023

Conversation

anthonysena
Copy link
Collaborator

Aims to fix #2887 by extending the concept set browser to only load the repository concept set list when the modal is activated.

@@ -298,7 +298,7 @@ define([
table.clear();

// Rebuild table from data source specified in binding
if (data.length > 0)
if (data && data.length > 0)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unrelated to the referenced issue. This fixes an error whereby the data object is not defined and so calling .length causes an error in the browser.

await refreshToken();
if (config.userAuthenticationEnabled) {
await refreshToken();
}
return result;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is also unrelated to the referenced issue. This addition fixes a bug that prevents running Atlas when security is disabled.

@anthonysena anthonysena added this to the v2.14 milestone Oct 2, 2023
@chrisknoll
Copy link
Collaborator

Suggestion (sorry I didn't try this myself): I noticed you have set up subscriptions (make sure you dispose them) to check if the showModal observable changes, and it is true, to do the concept set fetch....

I think the problem is that inside the modal component, we place the concept set component that does the fetch and it's just the lifecycle of the component that wants to do it: we instantiate 5 components so we will fetch the 5 concept sets.

To prevent the instantiation of the component could we put an if: block around the contents of the modal such that everything inside the module won't be instantiated until the showModal goes true, and then the component gets instantiated and the service call is made? (This is theoretically)

The end effect shoudl be the same as what you have (ie: the if: binding observes the showModal and will control the load) but without creating addiitional manual subscriptions that you need to clean up.

@anthonysena
Copy link
Collaborator Author

Suggestion (sorry I didn't try this myself): I noticed you have set up subscriptions (make sure you dispose them) to check if the showModal observable changes, and it is true, to do the concept set fetch....

That's correct - I need to clean up the subscription for sure.

I think the problem is that inside the modal component, we place the concept set component that does the fetch and it's just the lifecycle of the component that wants to do it: we instantiate 5 components so we will fetch the 5 concept sets.

To prevent the instantiation of the component could we put an if: block around the contents of the modal such that everything inside the module won't be instantiated until the showModal goes true, and then the component gets instantiated and the service call is made? (This is theoretically)

In theory that makes sense and would work well. What I recall from the code base is that the component for displaying the concept set is used in a number of places. So, my thinking was that by extending the component to be "modal aware" through its exposed parameter list, it would make modifying other things in Atlas a bit easier so that we only need to worry about where it is used modally vs. having to think about decorating those code blocks where it is used modally. They are functionally equivalent in my mind so I don't have a strong opinion either way.

The end effect shoudl be the same as what you have (ie: the if: binding observes the showModal and will control the load) but without creating addiitional manual subscriptions that you need to clean up.

Agreed - in the meantime, I will update this PR to clean up the subscription but if we want to go with the if: block approach we can close this out in favor of that set of changes.

@anthonysena
Copy link
Collaborator Author

@chrisknoll I've updated this PR to use the if: approach you described and removed the subscription. It should be ready for review now.

Copy link
Collaborator

@chrisknoll chrisknoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making the requested changes.

@anthonysena anthonysena merged commit 427a622 into master Oct 24, 2023
2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the issue-2887-cd-editor-cs-extra-calls branch October 24, 2023 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cohort definition editor loads full list of concept sets multiple times
2 participants