mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 03:16:37 +00:00
refactor: listen to db changes for outliner pipeline
This commit is contained in:
@@ -116,8 +116,8 @@
|
||||
|
||||
;; only save when user's idle
|
||||
|
||||
;; TODO: pass as a parameter
|
||||
(defonce *sync-search-indice-f (atom nil))
|
||||
(def *db-listener (atom nil))
|
||||
|
||||
(defn- repo-listen-to-tx!
|
||||
[repo conn]
|
||||
(d/listen! conn :persistence
|
||||
@@ -138,14 +138,8 @@
|
||||
(state/set-last-transact-time! repo (util/time-ms))
|
||||
(persist-if-idle! repo)))
|
||||
|
||||
;; rebuild search indices
|
||||
(let [data (:tx-data tx-report)
|
||||
datoms (filter
|
||||
(fn [datom]
|
||||
(contains? #{:block/name :block/content} (:a datom)))
|
||||
data)]
|
||||
(when-let [f @*sync-search-indice-f]
|
||||
(f datoms)))))))
|
||||
(when-let [db-listener @*db-listener]
|
||||
(db-listener repo tx-report))))))
|
||||
|
||||
(defn listen-and-persist!
|
||||
[repo]
|
||||
|
||||
Reference in New Issue
Block a user