mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-11-10 05:34:44 +00:00
moved from details to localStorage
This commit is contained in:
parent
1484a882b2
commit
dd0bcbe57d
@ -179,15 +179,6 @@ function setupUpdate(){
|
|||||||
|
|
||||||
newData["reviewID"] = currID;
|
newData["reviewID"] = currID;
|
||||||
|
|
||||||
//Get diff of tags and update storage
|
|
||||||
//Note: we can either get the difference twice or keep track when we delete and add
|
|
||||||
//if keep track also need to make sure that a tag doesn't end up on both list
|
|
||||||
let deletedTags = currReview["tags"].filter(x => !newData["tags"].includes(x));
|
|
||||||
let addedTags = newData["tags"].filter(x => !currReview["tags"].includes(x));
|
|
||||||
|
|
||||||
deleteTagsFromStorage(currID, deletedTags);
|
|
||||||
addTagsToStorage(currID, addedTags);
|
|
||||||
|
|
||||||
updateReviewToStorage(currID, newData);
|
updateReviewToStorage(currID, newData);
|
||||||
|
|
||||||
updateDiv.classList.add("hidden");
|
updateDiv.classList.add("hidden");
|
||||||
|
@ -40,6 +40,14 @@ export function getReviewFromStorage(ID){
|
|||||||
* @param {Object} review to store
|
* @param {Object} review to store
|
||||||
*/
|
*/
|
||||||
export function updateReviewToStorage(ID, review){
|
export function updateReviewToStorage(ID, review){
|
||||||
|
let oldReview = JSON.parse(localStorage.getItem(`review${ID}`));
|
||||||
|
|
||||||
|
//Get diff of tags and update storage
|
||||||
|
let deletedTags = oldReview["tags"].filter(x => !review["tags"].includes(x));
|
||||||
|
let addedTags = review["tags"].filter(x => !oldReview["tags"].includes(x));
|
||||||
|
deleteTagsFromStorage(currID, deletedTags);
|
||||||
|
addTagsToStorage(currID, addedTags);
|
||||||
|
|
||||||
// set the review entry with ID to the review object
|
// set the review entry with ID to the review object
|
||||||
localStorage.setItem(`review${ID}`, JSON.stringify(review));
|
localStorage.setItem(`review${ID}`, JSON.stringify(review));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user