mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 09:22:38 +00:00
Simplify history loading
This commit is contained in:
@@ -75,21 +75,9 @@ export async function loadHistory(brew){
|
|||||||
historyKeys.push(getKeyBySlot(brew, i));
|
historyKeys.push(getKeyBySlot(brew, i));
|
||||||
};
|
};
|
||||||
|
|
||||||
const history = [];
|
|
||||||
// Load all keys from IDB at once
|
// Load all keys from IDB at once
|
||||||
await IDB.getMany(historyKeys, await createHBStore())
|
const dataArray = await IDB.getMany(historyKeys, await createHBStore());
|
||||||
.then((dataArray)=>{
|
return dataArray.map((data)=>{ return data ?? DEFAULT_HISTORY_ITEM; });
|
||||||
return dataArray.forEach((data)=>{
|
|
||||||
history.push(data ?? DEFAULT_HISTORY_ITEM);
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(()=>{
|
|
||||||
historyKeys.forEach(()=>{
|
|
||||||
history.push(DEFAULT_HISTORY_ITEM);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return history;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateHistory(brew) {
|
export async function updateHistory(brew) {
|
||||||
|
|||||||
Reference in New Issue
Block a user