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

[DUOS-2907, DUOS-2917][risk=no] Bug fix: Update use effect handler #2457

Merged
merged 3 commits into from
Feb 8, 2024
Merged
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
32 changes: 18 additions & 14 deletions src/pages/DatasetSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,29 @@ export const DatasetSearch = (props) => {
const version = versions[key] === undefined ? versions['/custom'] : versions[key];
const isInstitutionQuery = key === 'myinstitution';

const fullQuery = assembleFullQuery(isSigningOfficial, isInstitutionQuery, version.query);
const isInstitutionSet = institutionId === undefined && isInstitutionQuery;

useEffect(() => {
const init = async () => {
if (institutionId === undefined && isInstitutionQuery) {
Notifications.showError({ text: 'You must set an institution in your profile to view the `myinstitution` data library' });
props.history.push('/profile');
return;
}
try {
const query = assembleFullQuery(isSigningOfficial, isInstitutionQuery, version.query);
await DataSet.searchDatasetIndex(query).then((datasets) => {
setDatasets(datasets);
setLoading(false);
});
} catch (error) {
Notifications.showError({ text: 'Failed to load Elasticsearch index' });
if (loading) {
if (isInstitutionSet) {
Notifications.showError({ text: 'You must set an institution in your profile to view the `myinstitution` data library' });
props.history.push('/profile');
return;
}
try {
await DataSet.searchDatasetIndex(fullQuery).then((datasets) => {
setDatasets(datasets);
setLoading(false);
});
} catch (error) {
Notifications.showError({ text: 'Failed to load Elasticsearch index' });
}
}
};
init();
}, [institutionId, isInstitutionQuery, isSigningOfficial, props.history, version.query]);
}, [loading, isInstitutionSet, fullQuery, props.history]);

return (
loading ?
Expand Down
Loading