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

Fix/discovery load order wrong #1676

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Discovery/index.tsx
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am open to other ideas.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this can also be done at

let studiesToSet;
by adding some checks there to compare the length of rawStudies and studies. If studies already exists and the length of rawStudies is less then studies, means the larger batch has already been processed and we should stop processing further but to return instead.
This way we can potentially skip some steps downstream.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure why, but studies is always null in that fetchRawStudies callback. I think the scope of the callback function is still holding the old component's studies

You can see this behavior here: demo/logging-studies

But yeah, the studies prop is always null during the fetchRawStudies request and callback :(
Screenshot 2025-02-24 at 10 25 03 AM

Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const populateStudiesWithConfigInfo = (studies, config) => {
});
};

let allStudies;

const DiscoveryWithMDSBackend: React.FC<{
userAggregateAuthMappings: any,
config: DiscoveryConfig,
Expand Down Expand Up @@ -128,7 +130,11 @@ const DiscoveryWithMDSBackend: React.FC<{
}),
);
}
return _.union(rawStudiesRegistered, rawStudiesUnregistered);
const result = _.union(rawStudiesRegistered, rawStudiesUnregistered);
if (numberOfBatchesLoaded > 0) {
allStudies = result;
}
return allStudies || result;
}
fetchRawStudies().then((rawStudies) => {
let studiesToSet;
Expand Down
Loading