fix: ui not synced with final db

This commit is contained in:
Tienson Qin
2026-01-15 14:57:10 +08:00
parent f6114afe47
commit 3af21b848d
3 changed files with 12 additions and 5 deletions

View File

@@ -356,7 +356,7 @@
(when (and conn (= local-tx remote-tx)) ; rebase
(when (empty? inflight)
(when-let [ws (:ws client)]
(when (ws-open? ws)
(when (and (ws-open? ws) (worker-state/online?))
(let [batch (pending-txs repo {:limit 50})]
(when (seq batch)
(let [tx-ids (mapv :tx-id batch)
@@ -596,9 +596,10 @@
(p/resolved nil)))))
(defn- apply-remote-tx!
[repo client tx-data & {:keys [expected-checksum]}]
[repo client tx-data* & {:keys [expected-checksum]}]
(if-let [conn (worker-state/get-datascript-conn repo)]
(let [local-txs (pending-txs repo)
(let [tx-data (keep-last-update @conn tx-data*)
local-txs (pending-txs repo)
*computed-checksum (atom nil)
reversed-tx-data (->> local-txs
(mapcat :reversed-tx)

View File

@@ -3,7 +3,8 @@
(:require [frontend.worker.db-listener :as db-listener]
[frontend.worker.rtc.client-op :as client-op]
[frontend.worker.rtc.debug-log :as rtc-debug-log]
[frontend.worker.rtc.gen-client-op :as gen-client-op]))
[frontend.worker.rtc.gen-client-op :as gen-client-op]
[frontend.worker.state :as worker-state]))
(comment
;; TODO: make it a qualified-keyword
@@ -15,7 +16,8 @@
{:keys [repo same-entity-datoms-coll id->same-entity-datoms]}
{:keys [tx-data tx-meta db-before db-after]}]
(when (and (client-op/rtc-db-graph? repo)
(:persist-op? tx-meta true))
(:persist-op? tx-meta true)
(not (:enabled? @worker-state/*db-sync-config)))
(rtc-debug-log/log-tx! repo tx-data tx-meta)
(let [e->a->add?->v->t (update-vals
id->same-entity-datoms

View File

@@ -123,6 +123,10 @@
[]
(:auth/id-token @*state))
(defn online?
[]
@(:thread-atom/online-event @*state))
(comment
(defn mobile?
[]