Skip to content

Commit

Permalink
Refactor storage method from sessionStorage to localStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
Gcolon021 committed Jul 23, 2024
1 parent 24a6071 commit 3d889fc
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ define(["jquery", "backbone", "handlebars", "text!studyAccess/studies-data.json"
}
}

// Cache the values (for demonstration, using localStoragae)
localStorage.setItem("availableStudiesCount", "" + countedStudies.length);

return {
availableStudiesCount: countedStudies.length,
};
Expand All @@ -96,7 +94,7 @@ define(["jquery", "backbone", "handlebars", "text!studyAccess/studies-data.json"
function getAvailableStudiesCount() {
if (!localStorage.getItem("availableStudiesCount") || !localStorage.getItem("cachedStudyDataHash") || localStorage.getItem("cachedStudyDataHash") !== studyAccessConfiguration.hashCode()) {
const { availableStudiesCount } = calculateAvailableStudiesAndParticipants();
return parse(availableStudiesCount);
return availableStudiesCount;
}
return parseInt(localStorage.getItem("availableStudiesCount"));
}
Expand Down

0 comments on commit 3d889fc

Please sign in to comment.