mirror of https://github.com/logseq/logseq
fix(sync): switch graph
parent
94cb71d8ba
commit
884d315f14
|
@ -73,14 +73,12 @@
|
|||
|
||||
(def ws-addr "wss://og96xf1si7.execute-api.us-east-2.amazonaws.com/production?graphuuid=%s")
|
||||
|
||||
|
||||
(def graphs-txid (persist-var/persist-var nil "graphs-txid"))
|
||||
|
||||
(defn- update-graphs-txid! [latest-txid graph-uuid repo]
|
||||
(persist-var/-reset-value! graphs-txid [graph-uuid latest-txid] repo)
|
||||
(persist-var/persist-save graphs-txid))
|
||||
|
||||
|
||||
(defn- ws-stop! [*ws]
|
||||
(swap! *ws (fn [o] (assoc o :stop true)))
|
||||
(.close (:ws @*ws)))
|
||||
|
@ -716,7 +714,9 @@
|
|||
diff-r
|
||||
(let [[diff-txns latest-txid min-txid] diff-r]
|
||||
(if (> min-txid @*txid) ;; if min-txid > @*txid, need to remote->local-full-sync
|
||||
{:need-remote->local-full-sync true}
|
||||
(do (println "min-txid" min-txid "request-txid" @*txid)
|
||||
{:need-remote->local-full-sync true})
|
||||
|
||||
(when (pos-int? latest-txid)
|
||||
(let [partitioned-filetxns (transduce (diffs->partitioned-filetxns 10)
|
||||
(completing (fn [r i] (conj r (reverse i)))) ;reverse
|
||||
|
|
|
@ -38,7 +38,9 @@
|
|||
[frontend.encrypt :as encrypt]
|
||||
[promesa.core :as p]
|
||||
[frontend.fs :as fs]
|
||||
[clojure.string :as string]))
|
||||
[clojure.string :as string]
|
||||
[frontend.util.persist-var :as persist-var]
|
||||
[frontend.fs.sync :as sync]))
|
||||
|
||||
;; TODO: should we move all events here?
|
||||
|
||||
|
@ -95,7 +97,12 @@
|
|||
(when-let [dir-name (config/get-repo-dir graph)]
|
||||
(fs/watch-dir! dir-name))
|
||||
(srs/update-cards-due-count!)
|
||||
(state/pub-event! [:graph/ready graph]))
|
||||
(state/pub-event! [:graph/ready graph])
|
||||
;; load persist-vars
|
||||
(persist-var/load-vars)
|
||||
|
||||
;; stop sync
|
||||
(sync/sync-stop))
|
||||
|
||||
(def persist-db-noti-m
|
||||
{:before #(notification/show!
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
(defn graph-txid-exists?
|
||||
[]
|
||||
(let [[graph-uuid txid] @sync/graphs-txid]
|
||||
(let [[graph-uuid _txid] @sync/graphs-txid]
|
||||
(some? graph-uuid)))
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
(config/get-file-path (state/get-current-repo) (str config/app-name "/" location ".edn")))
|
||||
|
||||
(defprotocol ILoad
|
||||
(-load [this]))
|
||||
(-load [this])
|
||||
(-loaded? [this]))
|
||||
|
||||
(defprotocol ISave
|
||||
(-save [this]))
|
||||
|
@ -39,6 +40,8 @@
|
|||
(-> o
|
||||
(assoc-in [repo :loaded?] true)
|
||||
(assoc-in [repo :value] content))))))))
|
||||
(-loaded? [_]
|
||||
(get-in @*value [(state/get-current-repo) :loaded?]))
|
||||
|
||||
ISave
|
||||
(-save [_]
|
||||
|
|
Loading…
Reference in New Issue