fix: loading whiteboard

pull/11177/head
Tienson Qin 2024-04-24 18:19:12 +08:00
parent 92cb360a2f
commit 6d7d4497ff
2 changed files with 5 additions and 9 deletions

View File

@ -122,8 +122,8 @@
(let [block (d/entity db (if (uuid? id) (let [block (d/entity db (if (uuid? id)
[:block/uuid id] [:block/uuid id]
id)) id))
get-children (fn [children] get-children (fn [block children]
(let [long-page? (> (count children) 500)] (let [long-page? (and (> (count children) 500) (not (contains? (:block/type block) "whiteboard")))]
(if long-page? (if long-page?
(map (fn [e] (map (fn [e]
(select-keys e [:db/id :block/uuid :block/page :block/left :block/parent :block/collapsed?])) (select-keys e [:db/id :block/uuid :block/page :block/left :block/parent :block/collapsed?]))
@ -148,7 +148,7 @@
{:block block' {:block block'
:properties (property-with-values db block)} :properties (property-with-values db block)}
children? children?
(assoc :children (get-children (:block/_parent block))))) (assoc :children (get-children block (:block/_parent block)))))
(cond-> (cond->
{:block (->> (d/pull db '[*] (:db/id block)) {:block (->> (d/pull db '[*] (:db/id block))
(with-tags db) (with-tags db)
@ -156,11 +156,7 @@
:properties (property-with-values db block)} :properties (property-with-values db block)}
children? children?
(assoc :children (assoc :children
(if (contains? (:block/type block) "whiteboard") (get-children block (:block/_page block))))))))
(->> (d/pull-many db '[*] (map :db/id (:block/_page block)))
(map #(with-block-refs db %))
(map mark-block-fully-loaded))
(get-children (:block/_page block)))))))))
(defn get-latest-journals (defn get-latest-journals
[db n] [db n]

View File

@ -220,7 +220,7 @@
(rum/defc tldraw-app-inner < rum/reactive (rum/defc tldraw-app-inner < rum/reactive
{:init (fn [state] {:init (fn [state]
(let [page-uuid (first (:rum/args state))] (let [page-uuid (first (:rum/args state))]
(db-async/<get-block (state/get-current-repo) (str page-uuid)) (db-async/<get-block (state/get-current-repo) page-uuid)
state))} state))}
[page-uuid block-id loaded-app set-loaded-app] [page-uuid block-id loaded-app set-loaded-app]
(when-not (state/sub-async-query-loading (str page-uuid)) (when-not (state/sub-async-query-loading (str page-uuid))