fix: blocks->vec-tree

experiment/tanstack-table
Tienson Qin 2024-06-21 11:31:52 +08:00
parent 194f7b7a41
commit 0b38900d70
1 changed files with 6 additions and 2 deletions

View File

@ -2,7 +2,8 @@
"Provides tree fns and INode protocol" "Provides tree fns and INode protocol"
(:require [logseq.db :as ldb] (:require [logseq.db :as ldb]
[logseq.db.frontend.property.util :as db-property-util] [logseq.db.frontend.property.util :as db-property-util]
[datascript.core :as d])) [datascript.core :as d]
[datascript.impl.entity :as de]))
(defprotocol INode (defprotocol INode
(-save [this txs-state conn repo date-formatter opts]) (-save [this txs-state conn repo date-formatter opts])
@ -50,7 +51,10 @@
(defn blocks->vec-tree (defn blocks->vec-tree
"`blocks` need to be in the same page." "`blocks` need to be in the same page."
[repo db blocks root-id] [repo db blocks root-id]
(let [[page? root] (get-root-and-page db root-id)] (let [blocks (map (fn [b] (if (de/entity? b)
(assoc (into {} b) :db/id (:db/id b))
b)) blocks)
[page? root] (get-root-and-page db root-id)]
(if-not root ; custom query (if-not root ; custom query
blocks blocks
(let [result (blocks->vec-tree-aux repo db blocks root)] (let [result (blocks->vec-tree-aux repo db blocks root)]