From 9f497c223b8ee2ff5037b0db6c855060c1bf0926 Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 9 Aug 2023 18:50:42 +0800 Subject: [PATCH] fix: UI crash --- src/main/frontend/components/block.cljs | 4 ++- .../handler/file_based/property/util.cljs | 31 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/frontend/components/block.cljs b/src/main/frontend/components/block.cljs index ccd8cd22a3..975a16a14c 100644 --- a/src/main/frontend/components/block.cljs +++ b/src/main/frontend/components/block.cljs @@ -3417,7 +3417,9 @@ (:db/id parent))))) {:debug-id page})])))))] - (and (:ref? config) (:group-by-page? config)) + (and (:ref? config) + (:group-by-page? config) + (vector? (first blocks))) [:div.flex.flex-col (let [blocks (sort-by (comp :block/journal-day first) > blocks)] (for [[page page-blocks] blocks] diff --git a/src/main/frontend/handler/file_based/property/util.cljs b/src/main/frontend/handler/file_based/property/util.cljs index ffaf817283..67f6a2ba74 100644 --- a/src/main/frontend/handler/file_based/property/util.cljs +++ b/src/main/frontend/handler/file_based/property/util.cljs @@ -363,21 +363,22 @@ ;; The future plan is to separate those properties from the block' content. (defn remove-built-in-properties [format content] - (let [trim-content (string/trim content)] - (if (or - (and (= format :markdown) - (string/starts-with? trim-content "```") - (string/ends-with? trim-content "```")) - (and (= format :org) - (string/starts-with? trim-content "#+BEGIN_SRC") - (string/ends-with? trim-content "#+END_SRC"))) - content - (let [built-in-properties* (built-in-properties) - content (reduce (fn [content key] - (remove-property format key content)) content built-in-properties*)] - (if (= format :org) - (string/replace-first content (re-pattern ":PROPERTIES:\n:END:\n*") "") - content))))) + (when content + (let [trim-content (string/trim content)] + (if (or + (and (= format :markdown) + (string/starts-with? trim-content "```") + (string/ends-with? trim-content "```")) + (and (= format :org) + (string/starts-with? trim-content "#+BEGIN_SRC") + (string/ends-with? trim-content "#+END_SRC"))) + content + (let [built-in-properties* (built-in-properties) + content (reduce (fn [content key] + (remove-property format key content)) content built-in-properties*)] + (if (= format :org) + (string/replace-first content (re-pattern ":PROPERTIES:\n:END:\n*") "") + content)))))) (defn add-page-properties [page-format properties-content properties]