summaryrefslogtreecommitdiff
path: root/src/Storage/IndexedDB.hs
diff options
context:
space:
mode:
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 ()