mirror of https://github.com/logseq/logseq
chore: ldb/transact! should takes `repo` instead of conn for UI
parent
3700592832
commit
d1af653273
|
@ -71,9 +71,10 @@
|
|||
(callback)))))
|
||||
|
||||
(defn transact!
|
||||
([conn tx-data]
|
||||
(transact! conn tx-data nil))
|
||||
([conn tx-data tx-meta]
|
||||
"`repo-or-conn`: repo for UI thread and conn for worker/node"
|
||||
([repo-or-conn tx-data]
|
||||
(transact! repo-or-conn tx-data nil))
|
||||
([repo-or-conn tx-data tx-meta]
|
||||
(let [tx-data (->> (common-util/fast-remove-nils tx-data)
|
||||
(remove empty?))
|
||||
request-finished? (request-finished?)]
|
||||
|
@ -91,14 +92,14 @@
|
|||
(not sync?)
|
||||
(assoc :request-id request-id))]
|
||||
(if sync?
|
||||
(f conn tx-data tx-meta')
|
||||
(f repo-or-conn tx-data tx-meta')
|
||||
(let [resp (p/deferred)]
|
||||
(when request-finished?
|
||||
(f conn tx-data tx-meta'))
|
||||
(f repo-or-conn tx-data tx-meta'))
|
||||
(let [value (if request-finished?
|
||||
{:response resp}
|
||||
{:response resp
|
||||
:callback #(f conn tx-data tx-meta')})]
|
||||
:callback #(f repo-or-conn tx-data tx-meta')})]
|
||||
(swap! *request-id->response assoc request-id value))
|
||||
resp)))))))
|
||||
|
||||
|
|
|
@ -83,8 +83,7 @@
|
|||
([repo tx-data]
|
||||
(transact! repo tx-data nil))
|
||||
([repo tx-data tx-meta]
|
||||
(when-let [conn (get-db repo false)]
|
||||
(ldb/transact! conn tx-data tx-meta))))
|
||||
(ldb/transact! repo tx-data tx-meta)))
|
||||
|
||||
(defn start!
|
||||
([repo]
|
||||
|
|
|
@ -79,10 +79,11 @@
|
|||
_ (ask-persist-permission!)]
|
||||
(ldb/register-transact-fn!
|
||||
(fn worker-transact!
|
||||
[_conn tx-data tx-meta]
|
||||
(transact! wrapped-worker (state/get-current-repo) tx-data
|
||||
[repo tx-data tx-meta]
|
||||
(let [repo' (if (string? repo) repo (state/get-current-repo))]
|
||||
(transact! wrapped-worker repo' tx-data
|
||||
;; not from remote(rtc)
|
||||
(assoc tx-meta :local-tx? true)))))
|
||||
(assoc tx-meta :local-tx? true))))))
|
||||
(p/catch (fn [error]
|
||||
(prn :debug "Can't init SQLite wasm")
|
||||
(js/console.error error)
|
||||
|
|
Loading…
Reference in New Issue