From 3dfe5c5751ac872435baf879f377bdcff8c4818e Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Thu, 1 Feb 2024 17:04:44 +0800 Subject: [PATCH] fix: load all pages and files when app starts --- deps/db/src/logseq/db/sqlite/common_db.cljs | 6 ++-- src/main/frontend/db_worker.cljs | 31 +++++++++++---------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/deps/db/src/logseq/db/sqlite/common_db.cljs b/deps/db/src/logseq/db/sqlite/common_db.cljs index 103dc2d10..7a3381c0b 100644 --- a/deps/db/src/logseq/db/sqlite/common_db.cljs +++ b/deps/db/src/logseq/db/sqlite/common_db.cljs @@ -89,9 +89,9 @@ (defn get-initial-data "Returns initial data" [db] - (let [files (get-built-in-files db) - journals (get-latest-journals db 3)] - (concat files journals))) + (let [all-pages (get-all-pages db) + all-files (get-all-files db)] + (concat all-pages all-files))) (defn restore-initial-data "Given initial sqlite data and schema, returns a datascript connection" diff --git a/src/main/frontend/db_worker.cljs b/src/main/frontend/db_worker.cljs index 4f9ffc4ee..3b00e1d96 100644 --- a/src/main/frontend/db_worker.cljs +++ b/src/main/frontend/db_worker.cljs @@ -260,7 +260,7 @@ [_this repo & {:keys [close-other-db?] :or {close-other-db? true}}] (p/do! - (when close-other-db? + (when close-other-db? (close-other-dbs! repo)) (create-or-open-db! repo))) @@ -364,20 +364,21 @@ (when-let [conn (worker-state/get-datascript-conn repo)] (let [data (->> (sqlite-common-db/get-initial-data @conn) pr-str)] - (async/go - ;; TODO: after UI db transacted - (async/