diff --git a/src/main/frontend/db/listener.cljs b/src/main/frontend/db/listener.cljs deleted file mode 100644 index 591699bf9e..0000000000 --- a/src/main/frontend/db/listener.cljs +++ /dev/null @@ -1,20 +0,0 @@ -(ns frontend.db.listener - "DB listeners" - (:require [datascript.core :as d] - [frontend.db.conn :as conn])) - -(defonce *db-listener (atom nil)) - -(defn repo-listen-to-tx! - [repo conn] - (d/listen! conn :persistence - (fn [tx-report] - (when (not (:new-graph? (:tx-meta tx-report))) ; skip initial txs - (when-let [db-listener @*db-listener] - (db-listener repo tx-report)))))) - -(defn listen-and-persist! - [repo] - (when-let [conn (conn/get-db repo false)] - (d/unlisten! conn :persistence) - (repo-listen-to-tx! repo conn))) diff --git a/src/main/frontend/db_worker.cljs b/src/main/frontend/db_worker.cljs index 9f5e7fcd1e..5c8e5ddc7b 100644 --- a/src/main/frontend/db_worker.cljs +++ b/src/main/frontend/db_worker.cljs @@ -270,7 +270,8 @@ context (if (string? context) (edn/read-string context) context) - _ (when context (state/set-context! context))] + _ (when context (state/set-context! context)) + tx-meta' (dissoc tx-meta :insert-blocks?)] (when-not (and (:create-today-journal? tx-meta) (:today-journal-name tx-meta) (d/entity @conn [:block/name (:today-journal-name tx-meta)])) ; today journal created already diff --git a/src/main/frontend/handler.cljs b/src/main/frontend/handler.cljs index 610dc90775..0f027b4794 100644 --- a/src/main/frontend/handler.cljs +++ b/src/main/frontend/handler.cljs @@ -40,11 +40,9 @@ [lambdaisland.glogi :as log] [promesa.core :as p] [frontend.mobile.core :as mobile] - [frontend.db.listener :as db-listener] [cljs-bean.core :as bean] [frontend.handler.test :as test] - [frontend.persist-db.browser :as db-browser] - [frontend.persist-db :as persist-db])) + [frontend.persist-db.browser :as db-browser])) (defn- set-global-error-notification! [] @@ -76,7 +74,6 @@ (repo-config-handler/start {:repo repo})) (p/then (fn [] - (db-listener/listen-and-persist! repo) ;; try to load custom css only for current repo (ui-handler/add-style-if-exists!) diff --git a/src/main/frontend/handler/events.cljs b/src/main/frontend/handler/events.cljs index 09b6430174..7e3d970477 100644 --- a/src/main/frontend/handler/events.cljs +++ b/src/main/frontend/handler/events.cljs @@ -73,7 +73,6 @@ [logseq.common.config :as common-config] [promesa.core :as p] [rum.core :as rum] - [frontend.db.listener :as db-listener] [frontend.persist-db.browser :as db-browser] [frontend.db.rtc.debug-ui :as rtc-debug-ui] [frontend.modules.outliner.pipeline :as pipeline] @@ -550,7 +549,6 @@ (catch :default e (js/console.error e))) (state/set-current-repo! current-repo) - (db-listener/listen-and-persist! current-repo) (repo-config-handler/restore-repo-config! current-repo) (when graph-switch-f (graph-switch-f current-repo true)) (.watch mobile-util/fs-watcher #js {:path current-repo-dir}) diff --git a/src/main/frontend/handler/repo.cljs b/src/main/frontend/handler/repo.cljs index 0a9663b6e2..bacab7566c 100644 --- a/src/main/frontend/handler/repo.cljs +++ b/src/main/frontend/handler/repo.cljs @@ -35,8 +35,7 @@ [clojure.core.async :as async] [frontend.mobile.util :as mobile-util] [medley.core :as medley] - [logseq.common.path :as path] - [frontend.db.listener :as db-listener])) + [logseq.common.path :as path])) ;; Project settings should be checked in two situations: ;; 1. User changes the config.edn directly in logseq.com (fn: alter-file) @@ -367,8 +366,7 @@ (state/set-current-repo! repo) (db/start-db-conn! repo (merge opts - {:listen-handler db-listener/listen-and-persist! - :db-graph? (config/db-based-graph? repo)}))) + {:db-graph? (config/db-based-graph? repo)}))) (defn- setup-demo-repo-if-not-exists-impl! [] @@ -378,7 +376,7 @@ repo-dir (config/get-repo-dir repo)] (p/do! (fs/mkdir-if-not-exists repo-dir) ;; create memory://local (state/set-current-repo! repo) - (db/start-db-conn! repo {:listen-handler db-listener/listen-and-persist!}) + (db/start-db-conn! repo {}) (when-not config/publishing? (let [dummy-notes (t :tutorial/dummy-notes)] (create-dummy-notes-page repo dummy-notes))) @@ -416,7 +414,6 @@ (when (config/global-config-enabled?) (global-config-handler/restore-global-config!)) ;; Don't have to unlisten the old listener, as it will be destroyed with the conn - (db-listener/listen-and-persist! repo) (ui-handler/add-style-if-exists!) (state/set-db-restoring! false))) diff --git a/src/main/frontend/handler/web/nfs.cljs b/src/main/frontend/handler/web/nfs.cljs index 1b72b8f792..5185aea7ae 100644 --- a/src/main/frontend/handler/web/nfs.cljs +++ b/src/main/frontend/handler/web/nfs.cljs @@ -21,7 +21,6 @@ [lambdaisland.glogi :as log] [logseq.common.util :as common-util] [promesa.core :as p] - [frontend.db.listener :as db-listener] [frontend.persist-db :as persist-db])) (defn remove-ignore-files @@ -297,8 +296,7 @@ (search/reset-indice! repo) (db/remove-conn! repo) (db/clear-query-state!) - (db/start-db-conn! repo {:listen-handler db-listener/listen-and-persist! - :db-graph? (config/db-based-graph? repo)}) + (db/start-db-conn! repo {:db-graph? (config/db-based-graph? repo)}) (reload-dir! repo {:re-index? true :ok-handler ok-handler})))) diff --git a/src/main/frontend/publishing.cljs b/src/main/frontend/publishing.cljs index 746f65f158..1b56d1aa9e 100644 --- a/src/main/frontend/publishing.cljs +++ b/src/main/frontend/publishing.cljs @@ -6,7 +6,6 @@ [datascript.core :as d] [frontend.db :as db] [frontend.db.conn :as conn] - [frontend.db.listener :as db-listener] [rum.core :as rum] [frontend.handler.route :as route-handler] [frontend.page :as page] @@ -103,8 +102,6 @@ (restore-from-transit-str!) (shortcut/refresh!) (events/run!) - ;; actually, there's no persist for publishing - (db-listener/listen-and-persist! (state/get-current-repo)) (start)) (defn stop []