From aa68762294700df2f625b9407af982d320523a04 Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Wed, 9 Oct 2024 15:59:11 +1300 Subject: [PATCH] Simplify historyCheck logic --- client/homebrew/utils/versionHistory.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/client/homebrew/utils/versionHistory.js b/client/homebrew/utils/versionHistory.js index bf987bb1f..387ff1f5a 100644 --- a/client/homebrew/utils/versionHistory.js +++ b/client/homebrew/utils/versionHistory.js @@ -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){