summaryrefslogtreecommitdiff
path: root/src/Storage/IndexedDB.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-02-10 12:07:59 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2026-02-10 12:39:34 +0100
commitf79d7088766b99421c56d85244bccdfd94f8670f (patch)
tree8962a6510934bef7601f0dea6b9720b24422d8e6 /src/Storage/IndexedDB.hs
parentccf3ccb7e1e8d839c000854b9078a1b143c791e3 (diff)
Cache storage
Diffstat (limited to 'src/Storage/IndexedDB.hs')
-rw-r--r--src/Storage/IndexedDB.hs28
1 files changed, 1 insertions, 27 deletions
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 ()