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 bugs with storing version number and update version to use August 13 dataset releases #236

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
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
30 changes: 15 additions & 15 deletions src/components/DatasetsListViewer/DatasetsListDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,20 @@ const DatasetsListDialog = (props) => {
datasets.forEach( node => node.attributes ? node.attributes.lowerCaseLabel = node.attributes?.label?.[0]?.toLowerCase() : null );
datasets = datasets.filter( node => node?.attributes?.statusOnPlatform?.[0]?.includes(PUBLISHED) );


let version = config.version;
let datasetStorage = {};
if ( version !== undefined && JSON.parse(localStorage.getItem(config.datasetsStorage))?.version !== version ) {
let parsedDatasets = []
datasets.forEach( node => {
parsedDatasets.push({ name : node.name , doi : node.attributes?.hasDoi?.[0], label : node.attributes ? node.attributes.lowerCaseLabel : null});
});
datasetStorage = {
version : version,
datasets : parsedDatasets
}

localStorage.setItem(config.datasetsStorage, JSON.stringify(datasetStorage));
dispatch(setDatasetsList(datasetStorage.datasets));
setFilteredDatasets(datasetStorage.datasets);
let parsedDatasets = []
datasets?.forEach( node => {
parsedDatasets.push({ name : node.name , doi : node.attributes?.hasDoi?.[0], label : node.attributes ? node.attributes?.lowerCaseLabel : null});
});
datasetStorage = {
version : version,
datasets : parsedDatasets
}

localStorage.setItem(config.datasetsStorage, JSON.stringify(datasetStorage));
dispatch(setDatasetsList(datasetStorage.datasets));
setFilteredDatasets(datasetStorage.datasets);
};
const summaryURL = config.repository_url + config.available_datasets;
fileHandler.get_remote_file(summaryURL, callback);
Expand Down Expand Up @@ -156,7 +153,10 @@ const DatasetsListDialog = (props) => {

useEffect(() => {
if ( open && datasets.length === 0 ) {
if ( localStorage.getItem(config.datasetsStorage) ) {
let version = config.version;
const storage = JSON.parse(localStorage.getItem(config.datasetsStorage));
const storageVersion = storage?.version
if ( localStorage.getItem(config.datasetsStorage) && version === storageVersion ) {
let storedDatasetsInfo = JSON.parse(localStorage.getItem(config.datasetsStorage));
dispatch(setDatasetsList(storedDatasetsInfo.datasets));
setFilteredDatasets(storedDatasetsInfo.datasets);
Expand Down
2 changes: 1 addition & 1 deletion src/config/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"datasetsButtonSubtitleText" : "Select a dataset to load"
},
"datasetsStorage" : "publishedDatasets",
"version" : "1.1"
"version" : "13-Aug-2024"
}
Loading