0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-10 00:32:45 +00:00

Set archiveBrew object directly

Co-authored-by: Trevor Buckner <calculuschild@gmail.com>
This commit is contained in:
G.Ambatte
2024-09-16 19:07:42 +12:00
committed by GitHub
parent dfd3b99232
commit 7a2fecf502

View File

@@ -36,26 +36,23 @@ function getVersionBySlot(brew, slot){
return output; return output;
}; };
function updateStoredBrew(brew, slot=0){ function updateStoredBrew(brew, slot = 0) {
const archiveBrew = {}; const archiveBrew = {
title : brew.title,
text : brew.text,
style : brew.style,
version : brew.version,
shareId : brew.shareId,
savedAt : brew?.savedAt || new Date(),
expireAt : new Date()
};
// Data from brew to be stored archiveBrew.expireAt.setMinutes(archiveBrew.expireAt.getMinutes() + HISTORY_SAVE_DELAYS[slot]);
archiveBrew.title = brew.title;
archiveBrew.text = brew.text;
archiveBrew.style = brew.style;
archiveBrew.version = brew.version;
archiveBrew.shareId = brew.shareId;
// Calculated values const key = getKeyBySlot(brew, slot);
archiveBrew.savedAt = brew?.savedAt || new Date(); localStorage.setItem(key, JSON.stringify(archiveBrew));
archiveBrew.expireAt = new Date(); }
archiveBrew.expireAt.setMinutes(archiveBrew.expireAt.getMinutes() + HISTORY_SAVE_DELAYS[slot]);
// Store data
const key = getKeyBySlot(brew, slot);
localStorage.setItem(key, JSON.stringify(archiveBrew));
return;
};
export function historyExists(brew){ export function historyExists(brew){
return Object.keys(localStorage) return Object.keys(localStorage)