Skip to content

Commit

Permalink
Resolve issue restoring backup with no images.
Browse files Browse the repository at this point in the history
Prefer `doseq` for safer iteration.
  • Loading branch information
samcf committed Oct 21, 2024
1 parent d2b2a91 commit 7e0c34c
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/main/ogres/app/provider/idb.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,9 @@
(.addEventListener tx "complete" resolve)
(.addEventListener rq "success"
(fn []
(loop [[x & xs] records]
(.put st x)
(if (seq xs)
(recur xs)
(.commit tx)))))))))
(doseq [record records]
(.put st record))
(.commit tx)))))))

(defui ^:private listeners []
(let [req (uix/use-context context)]
Expand Down Expand Up @@ -200,16 +198,14 @@
[table]
(let [req (uix/use-context context)]
(uix/use-callback
(fn [op data]
(fn [op records]
(js-await [idb req]
(js/Promise.
(fn [resolve]
(let [tx (.transaction idb #js [table] "readwrite")
st (.objectStore tx table)
op (aget st (name op))]
(.addEventListener tx "complete" resolve)
(loop [[x & xs] data]
(.call op st x)
(if (seq xs)
(recur xs)
(.commit tx)))))))) [table req])))
(doseq [record records]
(.call op st record))
(.commit tx)))))) [table req])))

0 comments on commit 7e0c34c

Please sign in to comment.