0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-06 18:42:40 +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]; return [key, archiveBrew];
} }
// Create a custom IDB store
async function createHBStore(){ async function createHBStore(){
return await IDB.createStore(HB_DB, HB_STORE); return await IDB.createStore(HB_DB, HB_STORE);
} }
// Determine if history data exists for this brew
export async function historyCheck(brew){ export async function historyCheck(brew){
const historyExists = await IDB.keys(await createHBStore()) const keys = await IDB.keys(await createHBStore())
.then((keys)=>{
return [...keys].some((key)=>{
return key.startsWith(`${HISTORY_PREFIX}-${brew.shareId}`);
});
})
.catch(()=>{return false;}); .catch(()=>{return false;});
return keys.some((key)=>{return key.startsWith(`${HISTORY_PREFIX}-${brew.shareId}`);});
return historyExists;
} }
export async function loadHistory(brew){ export async function loadHistory(brew){