Sfoglia il codice sorgente

handle more properties including title, icon, public and filters

Tienson Qin 2 anni fa
parent
commit
73ce46483b

+ 3 - 2
src/main/frontend/components/container.cljs

@@ -26,6 +26,7 @@
             [frontend.handler.user :as user-handler]
             [frontend.handler.whiteboard :as whiteboard-handler]
             [frontend.handler.recent :as recent-handler]
+            [frontend.handler.property.util :as pu]
             [frontend.mixins :as mixins]
             [frontend.mobile.action-bar :as action-bar]
             [frontend.mobile.footer :as footer]
@@ -96,9 +97,9 @@
 
 (defn get-page-icon [page-entity]
   (let [default-icon (ui/icon "page" {:extension? true})
-        from-properties (get-in (into {} page-entity) [:block/properties :icon])]
+        page-icon (pu/get-property page-entity :icon)]
     (or
-     (when (not= from-properties "") from-properties)
+     (when-not (string/blank? page-icon) page-icon)
      default-icon))) ;; Fall back to default if icon is undefined or empty
 
 (rum/defcs favorite-item <

+ 3 - 2
src/main/frontend/components/page.cljs

@@ -39,7 +39,8 @@
             [reitit.frontend.easy :as rfe]
             [rum.core :as rum]
             [logseq.graph-parser.util.page-ref :as page-ref]
-            [logseq.graph-parser.mldoc :as gp-mldoc]))
+            [logseq.graph-parser.mldoc :as gp-mldoc]
+            [frontend.handler.property.util :as pu]))
 
 (defn- get-page-name
   [state]
@@ -1119,7 +1120,7 @@
                               {:on-change (fn []
                                             (swap! *checks update idx not))})]
                [:td.icon.w-4.p-0.overflow-hidden
-                (when-let [icon (get-in page [:block/properties :icon])]
+                (when-let [icon (pu/get-property page :icon)]
                   icon)]
                [:td.name [:a {:on-click (fn [e]
                                           (.preventDefault e)

+ 3 - 2
src/main/frontend/components/page_menu.cljs

@@ -17,7 +17,8 @@
             [frontend.config :as config]
             [frontend.handler.user :as user-handler]
             [frontend.handler.file-sync :as file-sync-handler]
-            [logseq.common.path :as path]))
+            [logseq.common.path :as path]
+            [frontend.handler.property.util :as pu]))
 
 (defn- delete-page!
   [page-name]
@@ -68,7 +69,7 @@
           block? (and page (util/uuid-string? page-name) (not whiteboard?))
           contents? (= page-name "contents")
           properties (:block/properties page)
-          public? (true? (:public properties))
+          public? (true? (pu/lookup properties :public))
           favorites (:favorites (state/sub-config))
           favorited? (contains? (set (map util/page-name-sanity-lc favorites))
                                 page-name)

+ 0 - 1
src/main/frontend/components/whiteboard.cljs

@@ -137,7 +137,6 @@
   [page-name]
   (let [page-entity (model/get-page page-name)]
     (or
-     (get-in page-entity [:block/properties :title] nil)
      (:block/original-name page-entity)
      page-name)))
 

+ 3 - 2
src/main/frontend/handler/graph.cljs

@@ -5,7 +5,8 @@
             [frontend.db :as db]
             [logseq.db.default :as default-db]
             [frontend.state :as state]
-            [frontend.util :as util]))
+            [frontend.util :as util]
+            [frontend.handler.property.util :as pu]))
 
 (defn- build-links
   [links]
@@ -99,7 +100,7 @@
 
            pages-after-exclude-filter (cond->> pages-after-journal-filter
                                         (not excluded-pages?)
-                                        (remove (fn [p] (=  true (:exclude-from-graph-view (:block/properties p))))))
+                                        (remove (fn [p] (true? (pu/get-property p :exclude-from-graph-view)))))
 
             links (concat (seq relation)
                           (seq tagged-pages)

+ 3 - 2
src/main/frontend/handler/page.cljs

@@ -46,7 +46,8 @@
             [logseq.graph-parser.util.page-ref :as page-ref]
             [promesa.core :as p]
             [logseq.common.path :as path]
-            [medley.core :as medley]))
+            [medley.core :as medley]
+            [frontend.handler.property.util :as pu]))
 
 ;; FIXME: add whiteboard
 (defn- get-directory
@@ -954,7 +955,7 @@
 (defn get-filters
   [page-name]
   (let [properties (db/get-page-properties page-name)
-        properties-str (get properties :filters "{}")]
+        properties-str (or (pu/lookup properties :filters) "{}")]
     (try (reader/read-string properties-str)
          (catch :default e
            (log/error :syntax/filters e)))))