0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Simplify history loading

This commit is contained in:
G.Ambatte
2024-10-09 19:35:48 +13:00
parent 0bd3b53dd1
commit dc66d36b2d

View File

@@ -75,21 +75,9 @@ export async function loadHistory(brew){
historyKeys.push(getKeyBySlot(brew, i));
};
const history = [];
// Load all keys from IDB at once
await IDB.getMany(historyKeys, await createHBStore())
.then((dataArray)=>{
return dataArray.forEach((data)=>{
history.push(data ?? DEFAULT_HISTORY_ITEM);
});
})
.catch(()=>{
historyKeys.forEach(()=>{
history.push(DEFAULT_HISTORY_ITEM);
});
});
return history;
const dataArray = await IDB.getMany(historyKeys, await createHBStore());
return dataArray.map((data)=>{ return data ?? DEFAULT_HISTORY_ITEM; });
}
export async function updateHistory(brew) {