Skip to content

Commit

Permalink
Merge pull request #236 from MetaCell/development
Browse files Browse the repository at this point in the history
Fix bugs with storing version number and update version to use August 13 dataset releases
  • Loading branch information
jrmartin authored Sep 9, 2024
2 parents e3fee1d + 4ffaace commit 54d821e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
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"
}

0 comments on commit 54d821e

Please sign in to comment.