fix: references crash

This commit is contained in:
Tienson Qin
2023-02-20 23:56:18 +08:00
parent 0e365508be
commit ea213258b1
2 changed files with 17 additions and 5 deletions

View File

@@ -80,7 +80,8 @@
[promesa.core :as p]
[reitit.frontend.easy :as rfe]
[rum.core :as rum]
[shadow.loader :as loader]))
[shadow.loader :as loader]
[datascript.impl.entity :as e]))
(defn safe-read-string
([s]
@@ -569,7 +570,7 @@
(let [original-name (util/get-page-original-name page-entity)
s (cond untitled?
(t :untitled)
;; The page-name-in-block generated by the auto-complete is not page-name-sanitized
(string/starts-with? page-name "hls__")
(pdf-utils/fix-local-asset-pagename page-name)
@@ -3644,8 +3645,13 @@
(page-cp config page)
(when alias? [:span.text-sm.font-medium.opacity-50 " Alias"])]
(for [[parent blocks] parent-blocks]
(let [blocks' (map #(update % :block/children (fn [col]
(tree/non-consecutive-blocks->vec-tree col))) blocks)]
(let [blocks' (map (fn [b]
;; Block might be a datascript entity
(if (e/entity? b)
(db/pull (:db/id b))
(update b :block/children
(fn [col]
(tree/non-consecutive-blocks->vec-tree col))))) blocks)]
(rum/with-key
(breadcrumb-with-container blocks' config)
(:db/id parent))))