fix: graph with a configured home page displays journals view

fixes LOG-3058
pull/11102/head
Tienson Qin 2024-02-29 15:04:51 +08:00
parent dbc43fed9f
commit 73d6a9e729
1 changed files with 19 additions and 5 deletions

View File

@ -131,20 +131,34 @@
(concat [block]
(->> (keep :block/link children)
(map (fn [l]
(:block
(get-block-and-children db
(str (:block/uuid (d/entity db (:db/id l))))
false)))))
(d/pull db '[*] (:db/id l)))))
children))))
(defn get-full-page-and-blocks
[db page-name]
(let [data (get-block-and-children db (common-util/page-name-sanity-lc page-name) true)
result (first (tree-seq map? :children data))]
(cons (:block result)
(map #(dissoc % :children) (:children result)))))
(defn get-home-page
[db files]
(let [config (->> (some (fn [m] (when (= (:file/path m) "logseq/config.edn")
(:file/content m))) files)
(common-util/safe-read-string {}))
home-page (get-in config [:default-home :page])]
(when home-page
(get-full-page-and-blocks db (common-util/page-name-sanity-lc home-page)))))
(defn get-initial-data
"Returns initial data"
[db]
(let [favorites (get-favorites db)
latest-journals (get-latest-journals db 3)
all-files (get-all-files db)
home-page-data (get-home-page db all-files)
structured-blocks (get-structured-blocks db)]
(concat favorites latest-journals all-files structured-blocks)))
(concat favorites latest-journals all-files home-page-data structured-blocks)))
(defn restore-initial-data
"Given initial sqlite data and schema, returns a datascript connection"