mirror of
https://github.com/logseq/logseq.git
synced 2026-05-23 12:14:06 +00:00
move checksums to sync indicator
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
:graph-uuid nil
|
||||
:local-tx nil
|
||||
:remote-tx nil
|
||||
:local-checksum nil
|
||||
:remote-checksum nil
|
||||
:rtc-state :open
|
||||
:download-logs nil
|
||||
:upload-logs nil
|
||||
@@ -61,6 +63,8 @@
|
||||
:graph-uuid (:graph-uuid state)
|
||||
:local-tx (:local-tx state)
|
||||
:remote-tx (:remote-tx state)
|
||||
:local-checksum (:local-checksum state)
|
||||
:remote-checksum (:remote-checksum state)
|
||||
:rtc-state (if (:rtc-lock state) :open :close)))
|
||||
rtc-flows/rtc-state-flow)))]
|
||||
(reset! *update-detail-info-canceler canceler))))
|
||||
@@ -118,7 +122,7 @@
|
||||
[]
|
||||
(let [online? (hooks/use-flow-state flows/network-online-event-flow)
|
||||
[expand-debug? set-expand-debug!] (hooks/use-state false)
|
||||
{:keys [graph-uuid local-tx remote-tx rtc-state
|
||||
{:keys [graph-uuid local-tx remote-tx local-checksum remote-checksum rtc-state
|
||||
download-logs upload-logs misc-logs pending-local-ops pending-server-ops]}
|
||||
(hooks/use-flow-state (m/watch *detail-info))]
|
||||
[:div.rtc-info.flex.flex-col.gap-1.p-2.text-gray-11
|
||||
@@ -144,6 +148,8 @@
|
||||
graph-uuid (assoc :graph-uuid graph-uuid)
|
||||
local-tx (assoc :local-tx local-tx)
|
||||
remote-tx (assoc :remote-tx remote-tx)
|
||||
local-checksum (assoc :local-checksum local-checksum)
|
||||
remote-checksum (assoc :remote-checksum remote-checksum)
|
||||
rtc-state (assoc :rtc-state rtc-state))
|
||||
pprint/pprint
|
||||
with-out-str)]])
|
||||
|
||||
@@ -219,23 +219,10 @@
|
||||
:db/index true}]
|
||||
{:fix-db? true})))
|
||||
|
||||
(defn- normalize-sync-diagnostics
|
||||
[sync-diagnostics]
|
||||
(merge {:local-checksum nil
|
||||
:remote-checksum nil
|
||||
:local-tx nil
|
||||
:remote-tx nil}
|
||||
(select-keys sync-diagnostics [:local-checksum :remote-checksum :local-tx :remote-tx])))
|
||||
|
||||
(defn- with-sync-diagnostics
|
||||
[message sync-diagnostics]
|
||||
(str message "\n\n"
|
||||
"Sync diagnostics: " (pr-str (normalize-sync-diagnostics sync-diagnostics))))
|
||||
|
||||
(defn validate-db
|
||||
([conn]
|
||||
(validate-db nil conn nil))
|
||||
([_repo conn sync-diagnostics]
|
||||
([_repo conn _options]
|
||||
(fix-extends-cardinality! conn)
|
||||
(fix-icon-wrong-type! conn)
|
||||
(db-migrate/ensure-built-in-data-exists! conn)
|
||||
@@ -258,15 +245,11 @@
|
||||
{:msg "Validation errors"
|
||||
:errors errors}])
|
||||
(shared-service/broadcast-to-clients! :notification
|
||||
[(with-sync-diagnostics
|
||||
(str "Validation detected " (count errors) " invalid block(s). These blocks may be buggy. Attempting to fix invalid blocks. Run validation again to see if they were fixed.")
|
||||
sync-diagnostics)
|
||||
[(str "Validation detected " (count errors) " invalid block(s). These blocks may be buggy. Attempting to fix invalid blocks. Run validation again to see if they were fixed.")
|
||||
:warning false]))
|
||||
|
||||
(shared-service/broadcast-to-clients! :notification
|
||||
[(with-sync-diagnostics
|
||||
(str "Your graph is valid! " (assoc (db-validate/graph-counts db entities) :datoms datom-count))
|
||||
sync-diagnostics)
|
||||
[(str "Your graph is valid! " (assoc (db-validate/graph-counts db entities) :datoms datom-count))
|
||||
:success false]))
|
||||
{:errors errors
|
||||
:datom-count datom-count
|
||||
|
||||
@@ -44,8 +44,10 @@
|
||||
:get-pending-local-tx-count client-op/get-pending-local-tx-count
|
||||
:get-unpushed-asset-ops-count client-op/get-unpushed-asset-ops-count
|
||||
:get-local-tx client-op/get-local-tx
|
||||
:get-local-checksum client-op/get-local-checksum
|
||||
:get-graph-uuid client-op/get-graph-uuid
|
||||
:latest-remote-tx @*repo->latest-remote-tx}
|
||||
:latest-remote-tx @*repo->latest-remote-tx
|
||||
:latest-remote-checksum @*repo->latest-remote-checksum}
|
||||
repo))
|
||||
|
||||
(defn update-local-sync-checksum!
|
||||
|
||||
@@ -53,8 +53,10 @@
|
||||
:get-pending-local-tx-count client-op/get-pending-local-tx-count
|
||||
:get-unpushed-asset-ops-count client-op/get-unpushed-asset-ops-count
|
||||
:get-local-tx client-op/get-local-tx
|
||||
:get-local-checksum client-op/get-local-checksum
|
||||
:get-graph-uuid client-op/get-graph-uuid
|
||||
:latest-remote-tx @*repo->latest-remote-tx}
|
||||
:latest-remote-tx @*repo->latest-remote-tx
|
||||
:latest-remote-checksum @*repo->latest-remote-checksum}
|
||||
repo))
|
||||
|
||||
(defn- broadcast-rtc-state! [client]
|
||||
|
||||
@@ -31,8 +31,10 @@
|
||||
:get-pending-local-tx-count client-op/get-pending-local-tx-count
|
||||
:get-unpushed-asset-ops-count client-op/get-unpushed-asset-ops-count
|
||||
:get-local-tx client-op/get-local-tx
|
||||
:get-local-checksum client-op/get-local-checksum
|
||||
:get-graph-uuid client-op/get-graph-uuid
|
||||
:latest-remote-tx @sync-apply/*repo->latest-remote-tx}
|
||||
:latest-remote-tx @sync-apply/*repo->latest-remote-tx
|
||||
:latest-remote-checksum @sync-apply/*repo->latest-remote-checksum}
|
||||
repo))
|
||||
|
||||
(defn- broadcast-rtc-state!
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
get-pending-local-tx-count
|
||||
get-unpushed-asset-ops-count
|
||||
get-local-tx
|
||||
get-local-checksum
|
||||
get-graph-uuid
|
||||
latest-remote-tx]}
|
||||
latest-remote-tx
|
||||
latest-remote-checksum]}
|
||||
repo]
|
||||
(when (get-datascript-conn repo)
|
||||
(let [pending-local (if get-pending-local-tx-count
|
||||
@@ -30,6 +32,9 @@
|
||||
pending-asset (get-unpushed-asset-ops-count repo)
|
||||
local-tx (get-local-tx repo)
|
||||
remote-tx (get latest-remote-tx repo)
|
||||
local-checksum (when get-local-checksum
|
||||
(get-local-checksum repo))
|
||||
remote-checksum (get latest-remote-checksum repo)
|
||||
pending-server (when (and (number? local-tx) (number? remote-tx))
|
||||
(max 0 (- remote-tx local-tx)))
|
||||
graph-uuid (get-graph-uuid repo)]
|
||||
@@ -38,6 +43,8 @@
|
||||
:pending-server pending-server
|
||||
:local-tx local-tx
|
||||
:remote-tx remote-tx
|
||||
:local-checksum local-checksum
|
||||
:remote-checksum remote-checksum
|
||||
:graph-uuid graph-uuid})))
|
||||
|
||||
(defn normalize-online-users
|
||||
@@ -57,7 +64,8 @@
|
||||
(let [repo (:repo client)
|
||||
ws-state @(:ws-state client)
|
||||
online-users @(:online-users client)
|
||||
{:keys [pending-local pending-asset pending-server local-tx remote-tx graph-uuid]}
|
||||
{:keys [pending-local pending-asset pending-server
|
||||
local-tx remote-tx local-checksum remote-checksum graph-uuid]}
|
||||
(sync-counts-f repo)]
|
||||
{:rtc-state {:ws-state ws-state}
|
||||
:rtc-lock (= :open ws-state)
|
||||
@@ -67,6 +75,8 @@
|
||||
:pending-server-ops-count (or pending-server 0)
|
||||
:local-tx local-tx
|
||||
:remote-tx remote-tx
|
||||
:local-checksum local-checksum
|
||||
:remote-checksum remote-checksum
|
||||
:graph-uuid graph-uuid}))
|
||||
|
||||
(defn set-ws-state!
|
||||
|
||||
Reference in New Issue
Block a user