From f79d7088766b99421c56d85244bccdfd94f8670f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 10 Feb 2026 12:07:59 +0100 Subject: Cache storage --- src/Storage/IndexedDB.hs | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'src/Storage/IndexedDB.hs') diff --git a/src/Storage/IndexedDB.hs b/src/Storage/IndexedDB.hs index e13a549..4c4967d 100644 --- a/src/Storage/IndexedDB.hs +++ b/src/Storage/IndexedDB.hs @@ -21,6 +21,7 @@ import Foreign.Ptr import GHC.Wasm.Prim import JavaScript qualified as JS +import Storage.WatchList data IndexedDBStorage = IndexedDBStorage @@ -131,33 +132,6 @@ indexedDBStorage bsName = do newStorage IndexedDBStorage {..} -data WatchList = WatchList - { wlNext :: WatchID - , wlList :: [ WatchListItem ] - } - -data WatchListItem = WatchListItem - { wlID :: WatchID - , wlHead :: ( HeadTypeID, HeadID ) - , wlFun :: RefDigest -> IO () - } - -watchListAdd :: HeadTypeID -> HeadID -> (RefDigest -> IO ()) -> WatchList -> ( WatchList, WatchID ) -watchListAdd tid hid cb wl = ( wl', wlNext wl ) - where - wl' = wl - { wlNext = nextWatchID (wlNext wl) - , wlList = WatchListItem - { wlID = wlNext wl - , wlHead = (tid, hid) - , wlFun = cb - } : wlList wl - } - -watchListDel :: WatchID -> WatchList -> WatchList -watchListDel wid wl = wl { wlList = filter ((/= wid) . wlID) $ wlList wl } - - foreign import javascript unsafe "const req = window.indexedDB.open($1); req.onerror = (event) => { console.log(\"Error loading database.\"); }; req.onsuccess = (event) => { $2(req.result); }; req.onupgradeneeded = (event) => { const db = event.target.result; db.createObjectStore(\"objects\"); db.createObjectStore(\"heads\"); db.createObjectStore(\"keys\"); }" js_indexedDB_open :: JSString -> JSVal -> IO () -- cgit v1.2.3