0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Change empty slot logic

This commit is contained in:
G.Ambatte
2024-09-16 19:39:51 +12:00
parent 59f6f40ace
commit 8315df33ae

View File

@@ -33,7 +33,7 @@ function getVersionBySlot(brew, slot){
// - If it doesn't exist, pass default object
const key = getKeyBySlot(brew, slot);
const storedVersion = localStorage.getItem(key);
const output = storedVersion ? JSON.parse(storedVersion) : { ...DEFAULT_STORED_BREW, ...brew };
const output = storedVersion ? JSON.parse(storedVersion) : { expireAt: '2000-01-01T00:00:00.000Z', shareId: brew.shareId, noData: true };
return output;
};
@@ -84,7 +84,7 @@ export function updateHistory(brew) {
if(new Date() >= new Date(storedVersion.expireAt)){
for (let updateSlot = slot - 1; updateSlot>0; updateSlot--){
// Move data from updateSlot to updateSlot + 1
updateStoredBrew(history[updateSlot], updateSlot + 1);
!history[updateSlot]?.noData && updateStoredBrew(history[updateSlot], updateSlot + 1);
};
// Update the most recent brew