0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 22:32:45 +00:00

Simplify historyCheck logic

This commit is contained in:
G.Ambatte
2024-10-09 15:59:11 +13:00
parent 2a9402634f
commit aa68762294

View File

@@ -44,21 +44,16 @@ function parseBrewForStorage(brew, slot = 0) {
return [key, archiveBrew];
}
// Create a custom IDB store
async function createHBStore(){
return await IDB.createStore(HB_DB, HB_STORE);
}
// Determine if history data exists for this brew
export async function historyCheck(brew){
const historyExists = await IDB.keys(await createHBStore())
.then((keys)=>{
return [...keys].some((key)=>{
return key.startsWith(`${HISTORY_PREFIX}-${brew.shareId}`);
});
})
const keys = await IDB.keys(await createHBStore())
.catch(()=>{return false;});
return historyExists;
return keys.some((key)=>{return key.startsWith(`${HISTORY_PREFIX}-${brew.shareId}`);});
}
export async function loadHistory(brew){