Browse Source

fix :sidebar block loading

Tienson Qin 7 months ago
parent
commit
633b0518dc

+ 4 - 1
deps/db/src/logseq/db/common/sqlite.cljs

@@ -291,13 +291,16 @@
                             (get-structured-datoms db))
         recent-updated-pages (let [pages (get-recent-updated-pages db)]
                                (mapcat (fn [p] (d/datoms db :eavt (:db/id p))) pages))
+        contents-datoms (when-let [id (get-first-page-by-title db "Contents")]
+                          (d/datoms db :eavt id))
         data (distinct
               (concat idents
                       structured-datoms
                       favorites
                       recent-updated-pages
                       views
-                      all-files))]
+                      all-files
+                      contents-datoms))]
     {:schema schema
      :initial-data data}))
 

+ 1 - 1
src/main/frontend/components/block.cljs

@@ -919,7 +919,7 @@
                (:skip-async-load? (first args))
                (reset! *result page)
                :else
-               (p/let [result (db-async/<get-block (state/get-current-repo) page-id-or-name {:children? false :block-only? true
+               (p/let [result (db-async/<get-block (state/get-current-repo) page-id-or-name {:children? false
                                                                                              :skip-refresh? true
                                                                                              :including-property-vals? false})]
                  (reset! *result result)))

+ 10 - 14
src/main/frontend/components/page.cljs

@@ -165,7 +165,7 @@
          [:span.bullet-container.cursor
           [:span.bullet]]]
 
-        [:div.flex.flex-1
+        [:div.flex.flex-1.cursor-text
          {:on-drag-enter #(set-hover! true)
           :on-drag-over #(util/stop %)
           :on-drop drop-handler-fn
@@ -205,12 +205,10 @@
                                   (date/journal-title->int (date/today))))
                      (state/pub-event! [:journal/insert-template page-name])))
                  state)}
-  [state page-e {:keys [sidebar? whiteboard?] :as config}]
-  (when page-e
-    (let [page-name (or (:block/name page-e)
-                        (str (:block/uuid page-e)))
-          block-id (parse-uuid page-name)
-          block (get-block (or (:block/uuid page-e) (:block/name page-e)))
+  [state block* {:keys [sidebar? whiteboard?] :as config}]
+  (when-let [id (:db/id block*)]
+    (let [block (db/sub-block id)
+          block-id (:block/uuid block)
           block? (not (db/page? block))
           children (:block/_parent block)
           children (cond
@@ -225,13 +223,13 @@
       (cond
         (and
          (not block?)
-         (empty? children) page-e)
-        (dummy-block page-e)
+         (empty? children) block)
+        (dummy-block block)
 
         :else
         (let [document-mode? (state/sub :document/mode?)
               hiccup-config (merge
-                             {:id (if block? (str block-id) page-name)
+                             {:id (str (:block/uuid block))
                               :db/id (:db/id block)
                               :block? block?
                               :editor-box editor/box
@@ -246,10 +244,8 @@
                                        (string/blank? (:block/title (or link block'))))))]
             [:div.relative
              {:class (when add-button? "show-add-button")}
-             (page-blocks-inner page-e blocks config sidebar? whiteboard? block-id)
-             (let [args (if block-id
-                          {:block-uuid block-id}
-                          {:page page-name})]
+             (page-blocks-inner block blocks config sidebar? whiteboard? block-id)
+             (let [args {:block-uuid block-id}]
                (add-button args (:container-id config)))]))))))
 
 (rum/defc today-queries < rum/reactive

+ 167 - 144
src/main/frontend/components/right_sidebar.cljs

@@ -11,6 +11,7 @@
             [frontend.context.i18n :refer [t]]
             [frontend.date :as date]
             [frontend.db :as db]
+            [frontend.db.async :as db-async]
             [frontend.db.rtc.debug-ui :as rtc-debug-ui]
             [frontend.extensions.slide :as slide]
             [frontend.handler.editor :as editor-handler]
@@ -23,6 +24,7 @@
             [logseq.db :as ldb]
             [logseq.shui.ui :as shui]
             [medley.core :as medley]
+            [promesa.core :as p]
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]))
 
@@ -68,78 +70,84 @@
                          :sidebar-key sidebar-key} repo block-id {:indent? false})]
      (block-cp repo idx block)]))
 
-(defn build-sidebar-item
+(defn- <build-sidebar-item
   [repo idx db-id block-type *db-id init-key]
-  (case (keyword block-type)
-    :contents
-    [[:.flex.items-center (ui/icon "list-details" {:class "text-md mr-2"}) (t :right-side-bar/contents)]
-     (page-cp repo "contents")]
-
-    :help
-    [[:.flex.items-center (ui/icon "help" {:class "text-md mr-2"}) (t :right-side-bar/help)] (onboarding/help)]
-
-    :page-graph
-    [[:.flex.items-center (ui/icon "hierarchy" {:class "text-md mr-2"}) (t :right-side-bar/page-graph)]
-     (page/page-graph)]
-
-    :block-ref
-    #_:clj-kondo/ignore
-    (let [lookup (if (integer? db-id) db-id [:block/uuid db-id])]
-      (when-let [block (db/entity repo lookup)]
-        [(t :right-side-bar/block-ref)
-         (block-with-breadcrumb repo block idx [repo db-id block-type] true)]))
-
-    :block
-    #_:clj-kondo/ignore
-    (let [lookup (if (integer? db-id) db-id [:block/uuid db-id])]
-      (when-let [block (db/entity repo lookup)]
-        (block-with-breadcrumb repo block idx [repo db-id block-type] false)))
-
-    :page
-    (let [lookup (if (integer? db-id) db-id [:block/uuid db-id])
-          page (db/entity repo lookup)]
-      (if (ldb/page? page)
-        [[:.flex.items-center.page-title.gap-1
-          (icon/get-node-icon-cp page {:class "text-md"})
-          [:span.overflow-hidden.text-ellipsis (:block/title page)]]
-         (page-cp repo (str (:block/uuid page)))]
-        (block-with-breadcrumb repo page idx [repo db-id block-type] false)))
-
-    :search
-    [[:.flex.items-center.page-title
-      (ui/icon "search" {:class "text-md mr-2"})
-      (let [input (rum/react *db-id)
-            input' (if (string/blank? input) "Blank input" input)]
-        [:span.overflow-hidden.text-ellipsis input'])]
-     (rum/with-key
-       (cmdk/cmdk-block {:initial-input db-id
-                         :sidebar? true
-                         :on-input-change (fn [new-value]
-                                            (reset! *db-id new-value))
-                         :on-input-blur (fn [new-value]
-                                          (state/sidebar-replace-block! [repo db-id block-type]
-                                                                        [repo new-value block-type]))})
-       (str init-key))]
-
-    :page-slide-view
-    (let [page (db/entity db-id)]
-      [[:a.page-title {:href (rfe/href :page {:name (str (:block/uuid page))})}
-        (:block/title page)]
-       [:div.ml-2.slide.mt-2
-        (slide/slide page)]])
-
-    :shortcut-settings
-    [[:.flex.items-center (ui/icon "command" {:class "text-md mr-2"}) (t :help/shortcuts)]
-     (shortcut-settings)]
-    :rtc
-    [[:.flex.items-center (ui/icon "cloud" {:class "text-md mr-2"}) "(Dev) RTC"]
-     (rtc-debug-ui/rtc-debug-ui)]
-
-    :profiler
-    [[:.flex.items-center (ui/icon "cloud" {:class "text-md mr-2"}) "(Dev) Profiler"]
-     (profiler/profiler)]
-
-    ["" [:span]]))
+  (p/do!
+   (db-async/<get-block repo db-id)
+   (let [lookup (cond
+                  (integer? db-id) db-id
+                  (uuid? db-id) [:block/uuid db-id]
+                  :else nil)
+         entity (when lookup (db/entity repo lookup))
+         page? (ldb/page? entity)
+         block-render (fn []
+                        (when entity
+                          (if page?
+                            [[:.flex.items-center.page-title.gap-1
+                              (icon/get-node-icon-cp entity {:class "text-md"})
+                              [:span.overflow-hidden.text-ellipsis (:block/title entity)]]
+                             (page-cp repo (str (:block/uuid entity)))]
+                            (block-with-breadcrumb repo entity idx [repo db-id block-type] false))))]
+     (case (keyword block-type)
+       :contents
+       (when-let [page (db/get-page "Contents")]
+         [[:.flex.items-center (ui/icon "list-details" {:class "text-md mr-2"}) (t :right-side-bar/contents)]
+          (page-cp repo (str (:block/uuid page)))])
+
+       :help
+       [[:.flex.items-center (ui/icon "help" {:class "text-md mr-2"}) (t :right-side-bar/help)] (onboarding/help)]
+
+       :page-graph
+       [[:.flex.items-center (ui/icon "hierarchy" {:class "text-md mr-2"}) (t :right-side-bar/page-graph)]
+        (page/page-graph)]
+
+       :block-ref
+       (let [lookup (if (integer? db-id) db-id [:block/uuid db-id])]
+         (when-let [block (db/entity repo lookup)]
+           [(t :right-side-bar/block-ref)
+            (block-with-breadcrumb repo block idx [repo db-id block-type] true)]))
+
+       :block
+       (block-render)
+
+       :page
+       (block-render)
+
+       :search
+       [[:.flex.items-center.page-title
+         (ui/icon "search" {:class "text-md mr-2"})
+         (let [input (rum/react *db-id)
+               input' (if (string/blank? input) "Blank input" input)]
+           [:span.overflow-hidden.text-ellipsis input'])]
+        (rum/with-key
+          (cmdk/cmdk-block {:initial-input db-id
+                            :sidebar? true
+                            :on-input-change (fn [new-value]
+                                               (reset! *db-id new-value))
+                            :on-input-blur (fn [new-value]
+                                             (state/sidebar-replace-block! [repo db-id block-type]
+                                                                           [repo new-value block-type]))})
+          (str init-key))]
+
+       :page-slide-view
+       (when entity
+         [[:a.page-title {:href (rfe/href :page {:name (str (:block/uuid entity))})}
+           (:block/title entity)]
+          [:div.ml-2.slide.mt-2
+           (slide/slide entity)]])
+
+       :shortcut-settings
+       [[:.flex.items-center (ui/icon "command" {:class "text-md mr-2"}) (t :help/shortcuts)]
+        (shortcut-settings)]
+       :rtc
+       [[:.flex.items-center (ui/icon "cloud" {:class "text-md mr-2"}) "(Dev) RTC"]
+        (rtc-debug-ui/rtc-debug-ui)]
+
+       :profiler
+       [[:.flex.items-center (ui/icon "cloud" {:class "text-md mr-2"}) "(Dev) Profiler"]
+        (profiler/profiler)]
+
+       ["" [:span]]))))
 
 (defonce *drag-to
   (atom nil))
@@ -190,85 +198,100 @@
   [component _should-update?]
   component)
 
+(rum/defc sidebar-item-inner
+  [db-id {:keys [repo idx block-type collapsed? drag-from drag-to block-count *db-id init-key]}]
+  (let [[item set-item!] (hooks/use-state nil)]
+    (hooks/use-effect!
+     (fn []
+       (p/let [item (<build-sidebar-item repo idx db-id block-type *db-id init-key)]
+         (set-item! item)))
+     [])
+    (when item
+      [:<>
+       (when (zero? idx) (drop-indicator (dec idx) drag-to))
+       [:div.flex.sidebar-item.content.color-level.rounded-md.shadow-lg
+        {:class [(str "item-type-" (name block-type))
+                 (when collapsed? "collapsed")]}
+        (let [[title component] item]
+          [:div.flex.flex-col.w-full.relative
+           [:.flex.flex-row.justify-between.pr-2.sidebar-item-header.color-level.rounded-t-md
+            {:class         (when collapsed? "rounded-b-md")
+             :draggable     true
+             :on-context-menu (fn [e]
+                                (util/stop e)
+                                (shui/popup-show! e
+                                                  (actions-menu-content db-id idx block-type collapsed? block-count)
+                                                  {:as-dropdown? true
+                                                   :content-props {:on-click (fn [] (shui/popup-hide!))}}))
+             :on-drag-start (fn [event]
+                              (editor-handler/block->data-transfer! (:block/name (db/entity db-id)) event true)
+                              (reset! *drag-from idx))
+             :on-drag-end   (fn [_event]
+                              (when drag-to (state/sidebar-move-block! idx drag-to))
+                              (reset! *drag-to nil)
+                              (reset! *drag-from nil))
+             :on-pointer-up   (fn [event]
+                                (when (= (.-which (.-nativeEvent event)) 2)
+                                  (state/sidebar-remove-block! idx)))}
+
+            [:button.flex.flex-row.p-2.items-center.w-full.overflow-hidden
+             {:aria-expanded (str (not collapsed?))
+              :id            (str "sidebar-panel-header-" idx)
+              :aria-controls (str "sidebar-panel-content-" idx)
+              :on-click      (fn [event]
+                               (util/stop event)
+                               (state/sidebar-block-toggle-collapse! db-id))}
+             [:span.opacity-50.hover:opacity-100.flex.items-center.pr-1
+              (ui/rotating-arrow collapsed?)]
+             [:div.ml-1.font-medium.overflow-hidden.whitespace-nowrap
+              title]]
+            [:.item-actions.flex.items-center
+             (shui/button
+              {:title (t :right-side-bar/pane-more)
+               :class "px-3"
+               :variant :text
+               :on-click #(shui/popup-show!
+                           (.-target %)
+                           (actions-menu-content db-id idx block-type collapsed? block-count)
+                           {:as-dropdown? true
+                            :content-props {:on-click (fn [] (shui/popup-hide!))}})}
+              (ui/icon "dots"))
+
+             (shui/button
+              {:title (t :right-side-bar/pane-close)
+               :variant :text
+               :class "px-3"
+               :on-click #(state/sidebar-remove-block! idx)}
+              (ui/icon "x"))]]
+
+           [:div {:role "region"
+                  :id (str "sidebar-panel-content-" idx)
+                  :aria-labelledby (str "sidebar-panel-header-" idx)
+                  :class           (util/classnames [{:hidden  collapsed?
+                                                      :initial (not collapsed?)
+                                                      :sidebar-panel-content true
+                                                      :px-2    (not (contains? #{:search :shortcut-settings} block-type))}])}
+            (inner-component component (not drag-from))]
+           (when drag-from (drop-area idx))])]
+       (drop-indicator idx drag-to)])))
+
 (rum/defcs sidebar-item < rum/reactive
   {:init (fn [state] (assoc state
                             ::db-id (atom (nth (:rum/args state) 2))
                             ::init-key (random-uuid)))}
   [state repo idx db-id block-type block-count]
   (let [drag-from (rum/react *drag-from)
-        drag-to (rum/react *drag-to)
-        item (build-sidebar-item repo idx db-id block-type
-                                 (::db-id state)
-                                 (::init-key state))]
-    (when item
-      (let [collapsed? (state/sub [:ui/sidebar-collapsed-blocks db-id])]
-        [:<>
-         (when (zero? idx) (drop-indicator (dec idx) drag-to))
-         [:div.flex.sidebar-item.content.color-level.rounded-md.shadow-lg
-          {:class [(str "item-type-" (name block-type))
-                   (when collapsed? "collapsed")]}
-          (let [[title component] item]
-            [:div.flex.flex-col.w-full.relative
-             [:.flex.flex-row.justify-between.pr-2.sidebar-item-header.color-level.rounded-t-md
-              {:class         (when collapsed? "rounded-b-md")
-               :draggable     true
-               :on-context-menu (fn [e]
-                                  (util/stop e)
-                                  (shui/popup-show! e
-                                                    (actions-menu-content db-id idx block-type collapsed? block-count)
-                                                    {:as-dropdown? true
-                                                     :content-props {:on-click (fn [] (shui/popup-hide!))}}))
-               :on-drag-start (fn [event]
-                                (editor-handler/block->data-transfer! (:block/name (db/entity db-id)) event true)
-                                (reset! *drag-from idx))
-               :on-drag-end   (fn [_event]
-                                (when drag-to (state/sidebar-move-block! idx drag-to))
-                                (reset! *drag-to nil)
-                                (reset! *drag-from nil))
-               :on-pointer-up   (fn [event]
-                                  (when (= (.-which (.-nativeEvent event)) 2)
-                                    (state/sidebar-remove-block! idx)))}
-
-              [:button.flex.flex-row.p-2.items-center.w-full.overflow-hidden
-               {:aria-expanded (str (not collapsed?))
-                :id            (str "sidebar-panel-header-" idx)
-                :aria-controls (str "sidebar-panel-content-" idx)
-                :on-click      (fn [event]
-                                 (util/stop event)
-                                 (state/sidebar-block-toggle-collapse! db-id))}
-               [:span.opacity-50.hover:opacity-100.flex.items-center.pr-1
-                (ui/rotating-arrow collapsed?)]
-               [:div.ml-1.font-medium.overflow-hidden.whitespace-nowrap
-                title]]
-              [:.item-actions.flex.items-center
-               (shui/button
-                {:title (t :right-side-bar/pane-more)
-                 :class "px-3"
-                 :variant :text
-                 :on-click #(shui/popup-show!
-                             (.-target %)
-                             (actions-menu-content db-id idx block-type collapsed? block-count)
-                             {:as-dropdown? true
-                              :content-props {:on-click (fn [] (shui/popup-hide!))}})}
-                (ui/icon "dots"))
-
-               (shui/button
-                {:title (t :right-side-bar/pane-close)
-                 :variant :text
-                 :class "px-3"
-                 :on-click #(state/sidebar-remove-block! idx)}
-                (ui/icon "x"))]]
-
-             [:div {:role "region"
-                    :id (str "sidebar-panel-content-" idx)
-                    :aria-labelledby (str "sidebar-panel-header-" idx)
-                    :class           (util/classnames [{:hidden  collapsed?
-                                                        :initial (not collapsed?)
-                                                        :sidebar-panel-content true
-                                                        :px-2    (not (contains? #{:search :shortcut-settings} block-type))}])}
-              (inner-component component (not drag-from))]
-             (when drag-from (drop-area idx))])]
-         (drop-indicator idx drag-to)]))))
+        drag-to (rum/react *drag-to)]
+    (let [collapsed? (state/sub [:ui/sidebar-collapsed-blocks db-id])]
+      (sidebar-item-inner db-id {:repo repo
+                                 :idx idx
+                                 :block-type block-type
+                                 :collapsed? collapsed?
+                                 :drag-from drag-from
+                                 :drag-to drag-to
+                                 :block-count block-count
+                                 :*db-id (::db-id state)
+                                 :init-key (::init-key state)}))))
 
 (defn- get-page
   [match]

+ 1 - 1
src/main/frontend/components/views.cljs

@@ -175,7 +175,7 @@
 (rum/defc block-container
   [config row]
   (let [container (state/get-component :block/container)]
-    [:div.relative.w-full {:style {:min-height 29}}
+    [:div.relative.w-full {:style {:min-height 24}}
      (if row
        (container (assoc config :view? true) row)
        [:div])]))

+ 1 - 7
src/main/frontend/db/async.cljs

@@ -153,13 +153,7 @@
               (when-not skip-refresh?
                 (react/refresh-affected-queries! graph affected-keys))))
 
-          (cond
-            children-only?
-            children
-            (or children? block-only?)
-            block
-            :else
-            result'))))))
+          (if children-only? children block))))))
 
 (defn <get-blocks
   [graph ids* & {:as opts}]

+ 1 - 1
src/main/frontend/extensions/pdf/assets.cljs

@@ -193,7 +193,7 @@
                                       (:block/uuid hls-page)
                                       {:children? true
                                        :nested-children? false})]
-    {:highlights (keep :logseq.property.pdf/hl-value (:children result))}))
+    {:highlights (keep :logseq.property.pdf/hl-value result)}))
 
 (defn file-based-load-hls-data$
   [{:keys [hls-file]}]

+ 1 - 1
src/main/frontend/handler/editor.cljs

@@ -1764,7 +1764,7 @@
                                (p/let [e (db/entity [:block/uuid id])
                                        e' (or e
                                               (p/let [result (db-async/<get-block (state/get-current-repo) id {:children? false})]
-                                                (:block result)))]
+                                                result))]
                                  (when e'
                                    (assoc e' :block/title (:block/title b)))))))
                          nodes))]

+ 6 - 7
src/main/logseq/api.cljs

@@ -718,10 +718,9 @@
 (defn- <ensure-page-loaded
   [block-uuid-or-page-name]
   (p/let [repo (state/get-current-repo)
-          result (db-async/<get-block repo (str block-uuid-or-page-name)
-                                      {:children-props '[*]
-                                       :nested-children? true})
-          block (if (:block result) (:block result) result)
+          block (db-async/<get-block repo (str block-uuid-or-page-name)
+                                     {:children-props '[*]
+                                      :nested-children? true})
           _ (when-let [page-id (:db/id (:block/page block))]
               (when-let [page-uuid (:block/uuid (db/entity page-id))]
                 (db-async/<get-block repo page-uuid)))]
@@ -856,7 +855,7 @@
     (p/let [id (sdk-utils/uuid-or-throw-error block-uuid)
             block (<pull-block id)
             ;; Load all children blocks
-            _ (api-block/sync-children-blocks! block)]
+            _ (api-block/<sync-children-blocks! block)]
       (when block
         (when-let [sibling (ldb/get-left-sibling (db/entity (:db/id block)))]
           (get_block (:block/uuid sibling) opts))))))
@@ -866,7 +865,7 @@
     (p/let [id (sdk-utils/uuid-or-throw-error block-uuid)
             block (<pull-block id)
             ;; Load all children blocks
-            _ (api-block/sync-children-blocks! block)]
+            _ (api-block/<sync-children-blocks! block)]
       (when block
         (p/let [sibling (ldb/get-right-sibling (db/entity (:db/id block)))]
           (get_block (:block/uuid sibling) opts))))))
@@ -1071,7 +1070,7 @@
                                                                        :create-first-block? false
                                                                        :format              (state/get-preferred-format)}))]
     (when-let [block (db-model/get-page uuid-or-page-name)]
-      (-> (api-block/sync-children-blocks! block)
+      (-> (api-block/<sync-children-blocks! block)
           (p/then (fn []
                     (let [block' (first-child-of-block block)
                           opts (bean/->clj opts)

+ 48 - 49
src/main/logseq/api/block.cljs

@@ -1,37 +1,37 @@
 (ns logseq.api.block
   "Block related apis"
-  (:require [clojure.string :as string]
-            [frontend.db.model :as db-model]
-            [frontend.db.utils :as db-utils]
-            [cljs-bean.core :as bean]
-            [promesa.core :as p]
-            [frontend.state :as state]
+  (:require [cljs-bean.core :as bean]
+            [clojure.string :as string]
             [frontend.config :as config]
-            [frontend.modules.outliner.tree :as outliner-tree]
-            [frontend.modules.outliner.ui :as ui-outliner-tx]
             [frontend.db :as db]
             [frontend.db.async :as db-async]
             [frontend.db.conn :as conn]
-            [logseq.db.frontend.property :as db-property]
+            [frontend.db.model :as db-model]
+            [frontend.db.utils :as db-utils]
             [frontend.handler.db-based.property :as db-property-handler]
             [frontend.handler.db-based.property.util :as db-pu]
             [frontend.handler.page :as page-handler]
             [frontend.handler.property :as property-handler]
+            [frontend.modules.outliner.tree :as outliner-tree]
+            [frontend.modules.outliner.ui :as ui-outliner-tx]
+            [frontend.state :as state]
             [logseq.db :as ldb]
-            [logseq.sdk.utils :as sdk-utils]))
+            [logseq.db.frontend.property :as db-property]
+            [logseq.sdk.utils :as sdk-utils]
+            [promesa.core :as p]))
 
 (defn- encode-user-property-name
   [k]
   (if (string? k)
     (-> k (string/trim)
-      (string/replace "/" "")
-      (string/replace " " ""))
+        (string/replace "/" "")
+        (string/replace " " ""))
     k))
 
 (defn convert?to-built-in-property-name
   [property-name]
   (if (and (not (qualified-keyword? property-name))
-        (contains? #{:background-color} property-name))
+           (contains? #{:background-color} property-name))
     (keyword :logseq.property property-name)
     property-name))
 
@@ -52,17 +52,17 @@
 (defn into-readable-db-properties
   [properties]
   (some-> properties
-    (db-pu/readable-properties
-      {:original-key? true :key-fn str})))
+          (db-pu/readable-properties
+           {:original-key? true :key-fn str})))
 
 (defn into-properties
   ([block] (into-properties (state/get-current-repo) block))
   ([repo block]
    (if (some-> repo (config/db-based-graph?))
      (let [props (some->> block
-                   (filter (fn [[k _]] (db-property/property? k)))
-                   (into {})
-                   (into-readable-db-properties))
+                          (filter (fn [[k _]] (db-property/property? k)))
+                          (into {})
+                          (into-readable-db-properties))
            block (update block :block/properties merge props)
            block (apply dissoc (concat [block] (keys props)))]
        block)
@@ -79,10 +79,10 @@
                     (let [id (:db/id (ldb/get-case-page (conn/get-db) page))]
                       (if (nil? id)
                         (-> (page-handler/<create! page {:redirect? false :create-first-block? false})
-                          (p/then #(:db/id %)))
+                            (p/then #(:db/id %)))
                         id))))
-              (p/all)
-              (p/then (fn [vs] [ident :logseq.property/empty-placeholder vs true])))
+                (p/all)
+                (p/then (fn [vs] [ident :logseq.property/empty-placeholder vs true])))
             [ident value nil false]))]
     (if (not (db-utils/entity ident))
       (let [type (cond
@@ -92,49 +92,48 @@
                    :else :default)
             schema {:type type :cardinality (if multi? :many :one)}]
         (p/chain
-          (db-property-handler/upsert-property! ident schema {})
-          value-handle))
+         (db-property-handler/upsert-property! ident schema {})
+         value-handle))
       (value-handle))))
 
 (defn save-db-based-block-properties!
   [block properties]
   (when-let [block-id (and (seq properties) (:db/id block))]
     (let [properties (update-keys properties
-                       (fn [k] (get-db-ident-for-user-property-name k)))
+                                  (fn [k] (get-db-ident-for-user-property-name k)))
           *properties-page-refs (volatile! {})]
       (-> (for [ident (keys properties)]
             (p/let [ret (infer-property-value-type-to-save! ident (get properties ident))] ret))
-        (p/all)
-        (p/chain
-          (fn [props]
-            (->> props
-              (reduce (fn [a [k v vs multi?]]
-                        (if multi?
-                          (do (vswap! *properties-page-refs assoc k vs) a)
-                          (assoc a k v))) {})
-              (db-property-handler/set-block-properties! block-id)))
+          (p/all)
+          (p/chain
+           (fn [props]
+             (->> props
+                  (reduce (fn [a [k v vs multi?]]
+                            (if multi?
+                              (do (vswap! *properties-page-refs assoc k vs) a)
+                              (assoc a k v))) {})
+                  (db-property-handler/set-block-properties! block-id)))
           ;; handle page refs
-          (fn []
-            (when (seq @*properties-page-refs)
-              (doseq [[ident refs] @*properties-page-refs]
-                (-> (property-handler/remove-block-property! (state/get-current-repo) block-id ident)
-                  (p/then
-                    (fn []
-                      (if (seq refs)
-                        (ui-outliner-tx/transact!
-                          {:outliner-op :set-block-properties}
-                          (doseq [eid refs]
-                            (when (number? eid)
-                              (property-handler/set-block-property!
+           (fn []
+             (when (seq @*properties-page-refs)
+               (doseq [[ident refs] @*properties-page-refs]
+                 (-> (property-handler/remove-block-property! (state/get-current-repo) block-id ident)
+                     (p/then
+                      (fn []
+                        (if (seq refs)
+                          (ui-outliner-tx/transact!
+                           {:outliner-op :set-block-properties}
+                           (doseq [eid refs]
+                             (when (number? eid)
+                               (property-handler/set-block-property!
                                 (state/get-current-repo) block-id ident eid))))
-                        (db-property-handler/set-block-property! block-id ident :logseq.property/empty-placeholder))))))))
-          )))))
+                          (db-property-handler/set-block-property! block-id ident :logseq.property/empty-placeholder)))))))))))))
 
-(defn sync-children-blocks!
+(defn <sync-children-blocks!
   [block]
   (when block
     (db-async/<get-block (state/get-current-repo)
-      (:block/uuid (:block/parent block)) {:children? true})))
+                         (:block/uuid (:block/parent block)) {:children? true})))
 
 (defn get_block
   [id-or-uuid ^js opts]