From ebf900ba240bc8bf7279e1ebea169a77da3cc75a Mon Sep 17 00:00:00 2001 From: "G.Ambatte" Date: Wed, 30 Oct 2024 08:21:51 +1300 Subject: [PATCH] Remove Proxy version --- client/homebrew/utils/customIDBStore.js | 35 ------------------------- client/homebrew/utils/versionHistory.js | 4 +-- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/client/homebrew/utils/customIDBStore.js b/client/homebrew/utils/customIDBStore.js index ed65769a6..6a3c84400 100644 --- a/client/homebrew/utils/customIDBStore.js +++ b/client/homebrew/utils/customIDBStore.js @@ -1,40 +1,5 @@ import * as IDB from 'idb-keyval/dist/index.js'; -// The Proxy and the Wrapper _should_ be equivalent - -// IndexedDB Proxy - -export function initIDBProxy(db, store) { - - const PROP_LIST = [ - 'entries', - 'keys', - 'values', - 'clear', - 'get', - 'getMany', - 'set', - 'setMany', - 'update', - 'del', - 'delMany' - ]; - - const IDBHandler = { - get : (target, prop)=>{ - if(!PROP_LIST.includes(prop)){ return target[prop]; } - return function (...args) { - return target[prop].apply(target, [...args, target.createStore(db, store)]); - }; - } - }; - - return new Proxy(IDB, IDBHandler); -} - - -// IndexedDB Wrapper - export function initCustomStore(db, store){ const createCustomStore = async ()=>IDB.createStore(db, store); diff --git a/client/homebrew/utils/versionHistory.js b/client/homebrew/utils/versionHistory.js index d9a70c11d..ec3bd74e1 100644 --- a/client/homebrew/utils/versionHistory.js +++ b/client/homebrew/utils/versionHistory.js @@ -1,4 +1,4 @@ -import { initIDBProxy } from './customIDBStore.js'; +import { initCustomStore } from './customIDBStore.js'; export const HISTORY_PREFIX = 'HOMEBREWERY-HISTORY'; export const HISTORY_SLOTS = 5; @@ -28,7 +28,7 @@ const GARBAGE_COLLECT_DELAY = 28 * 24 * 60; const HB_DB = 'HOMEBREWERY-DB'; const HB_STORE = 'HISTORY'; -const IDB = initIDBProxy(HB_DB, HB_STORE); +const IDB = initCustomStore(HB_DB, HB_STORE); function getKeyBySlot(brew, slot){ // Return a string representing the key for this brew and history slot