Pārlūkot izejas kodu

Prefer to use ldb/{type}? check when possible

Tienson Qin 1 gadu atpakaļ
vecāks
revīzija
411b05e7ba
36 mainītis faili ar 131 papildinājumiem un 126 dzēšanām
  1. 4 3
      deps/db/script/validate_client_db.cljs
  2. 16 36
      deps/db/src/logseq/db.cljs
  3. 4 4
      deps/db/src/logseq/db/frontend/malli_schema.cljs
  4. 1 1
      deps/db/src/logseq/db/sqlite/common_db.cljs
  5. 28 0
      deps/db/src/logseq/db/sqlite/util.cljs
  6. 4 4
      deps/db/test/logseq/db/sqlite/create_graph_test.cljs
  7. 2 2
      deps/graph-parser/src/logseq/graph_parser/exporter.cljs
  8. 2 2
      deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs
  9. 3 2
      deps/graph-parser/test/logseq/graph_parser/extract_test.cljs
  10. 4 4
      deps/outliner/src/logseq/outliner/property.cljs
  11. 2 2
      src/main/frontend/components/cmdk/core.cljs
  12. 5 5
      src/main/frontend/components/db_based/page.cljs
  13. 1 1
      src/main/frontend/components/editor.cljs
  14. 1 1
      src/main/frontend/components/icon.cljs
  15. 4 3
      src/main/frontend/components/imports.cljs
  16. 6 6
      src/main/frontend/components/page.cljs
  17. 2 1
      src/main/frontend/components/page_menu.cljs
  18. 6 5
      src/main/frontend/components/property.cljs
  19. 3 3
      src/main/frontend/components/property/value.cljs
  20. 1 1
      src/main/frontend/components/reference.cljs
  21. 1 1
      src/main/frontend/components/right_sidebar.cljs
  22. 5 5
      src/main/frontend/db/model.cljs
  23. 1 1
      src/main/frontend/extensions/slide.cljs
  24. 2 2
      src/main/frontend/handler/db_based/recent.cljs
  25. 2 3
      src/main/frontend/handler/editor.cljs
  26. 1 1
      src/main/frontend/handler/graph.cljs
  27. 2 2
      src/main/frontend/handler/page.cljs
  28. 1 1
      src/main/frontend/routes.cljs
  29. 1 1
      src/main/frontend/worker/export.cljs
  30. 1 1
      src/main/frontend/worker/file.cljs
  31. 2 2
      src/main/frontend/worker/file/core.cljs
  32. 1 1
      src/main/frontend/worker/handler/page.cljs
  33. 4 4
      src/main/frontend/worker/handler/page/file_based/rename.cljs
  34. 3 3
      src/main/frontend/worker/rtc/remote_update.cljs
  35. 4 11
      src/main/frontend/worker/search.cljs
  36. 1 1
      src/main/logseq/api.cljs

+ 4 - 3
deps/db/script/validate_client_db.cljs

@@ -13,7 +13,8 @@
             ["path" :as node-path]
             ["os" :as os]
             [cljs.pprint :as pprint]
-            [malli.error :as me]))
+            [malli.error :as me]
+            [logseq.db :as ldb]))
 
 (defn validate-client-db
   "Validate datascript db as a vec of entity maps"
@@ -81,9 +82,9 @@
                                (count ent-maps) " entities, "
                                (count (filter :block/name ent-maps)) " pages, "
                                (count (filter :block/title ent-maps)) " blocks, "
-                               (count (filter #(= (:block/type %) "tag") ent-maps)) " tags, "
+                               (count (filter ldb/tag? ent-maps)) " tags, "
                                (count (filter #(seq (:block/tags %)) ent-maps)) " objects, "
-                               (count (filter #(= (:block/type %) "property") ent-maps)) " properties and "
+                               (count (filter ldb/property? ent-maps)) " properties and "
                                (count (mapcat db-property/properties ent-maps)) " property pairs"))
     (validate-client-db @conn ent-maps options)))
 

+ 16 - 36
deps/db/src/logseq/db.cljs

@@ -84,6 +84,14 @@
              (prn :debug-tx-data tx-data)
              (throw e))))))))
 
+(def page? sqlite-util/page?)
+(def tag? sqlite-util/tag?)
+(def property? sqlite-util/property?)
+(def closed-value? sqlite-util/closed-value?)
+(def whiteboard? sqlite-util/whiteboard?)
+(def journal? sqlite-util/journal?)
+(def hidden? sqlite-util/hidden?)
+
 (defn sort-by-order
   [blocks]
   (sort-by :block/order blocks))
@@ -99,16 +107,6 @@
   (when-let [e (d/entity db [:block/uuid block-uuid])]
     (get-block-and-children-aux e)))
 
-(defn whiteboard-page?
-  "Given a page entity or map, check if it is a whiteboard page"
-  [page]
-  (= (:block/type page) "whiteboard"))
-
-(defn journal-page?
-  "Given a page entity or map, check if it is a journal page"
-  [page]
-  (= (:block/type page) "journal"))
-
 (defn get-page-blocks
   "Return blocks of the designated page, without using cache.
    page-id - eid"
@@ -164,14 +162,6 @@
   (first (sort-by-order (:block/_parent block))))
 
 
-(defn hidden-page?
-  [page]
-  (when page
-    (if (string? page)
-      (or (string/starts-with? page "$$$")
-          (= common-config/favorites-page-name page))
-      (= (:block/type page) "hidden"))))
-
 (defn get-pages
   [db]
   (->> (d/q
@@ -181,7 +171,7 @@
           [(get-else $ ?page :block/title ?page-name) ?page-title]]
         db)
        (map first)
-       (remove hidden-page?)))
+       (remove hidden?)))
 
 (def get-first-page-by-name sqlite-common-db/get-first-page-by-name)
 
@@ -246,17 +236,17 @@
                                     (= 1 (count children))
                                     (contains? #{"" "-" "*"} (string/trim (:block/title first-child))))))
                                 (not (contains? built-in-pages name))
-                                (not (whiteboard-page? page))
+                                (not (whiteboard? page))
                                 (not (:block/_namespace page))
-                                (not (= (:block/type page) "property"))
+                                (not (property? page))
                                  ;; a/b/c might be deleted but a/b/c/d still exists (for backward compatibility)
                                 (not (and (string/includes? name "/")
-                                          (not (journal-page? page))))
+                                          (not (journal? page))))
                                 page))))
                          pages)
                         (remove false?)
                         (remove nil?)
-                        (remove hidden-page?))]
+                        (remove hidden?))]
     orphaned-pages))
 
 (defn has-children?
@@ -434,7 +424,7 @@
    (d/datoms db :avet :block/name)
    (distinct)
    (map #(d/entity db (:e %)))
-   (remove hidden-page?)
+   (remove hidden?)
    (remove (fn [page]
              (common-util/uuid-string? (:block/name page))))))
 
@@ -447,7 +437,7 @@
   "Whether property a built-in property for the specific class"
   [class-entity property-entity]
   (and (built-in? class-entity)
-       (= (:block/type class-entity) "tag")
+       (tag? class-entity)
        (built-in? property-entity)
        (contains? (set (map :db/ident (:class/schema.properties class-entity)))
                   (:db/ident property-entity))))
@@ -502,16 +492,6 @@
   [db]
   (when db (:kv/value (d/entity db :logseq.kv/graph-uuid))))
 
-(def page? sqlite-util/page?)
-(defn class?
-  [entity]
-  (= (:block/type entity) "tag"))
-(defn property?
-  [entity]
-  (= (:block/type entity) "property"))
-(defn closed-value?
-  [entity]
-  (= (:block/type entity) "closed value"))
 
 (def db-based-graph? entity-plus/db-based-graph?)
 
@@ -561,7 +541,7 @@
       (loop [current-parent parent]
         (when (and
                current-parent
-               (= (:block/type parent) "tag")
+               (tag? parent)
                (not (contains? @*classes (:db/id parent))))
           (swap! *classes conj (:db/id current-parent))
           (recur (:class/parent current-parent)))))

+ 4 - 4
deps/db/src/logseq/db/frontend/malli_schema.cljs

@@ -429,13 +429,13 @@
   (into
    [:multi {:dispatch (fn [d]
                         (cond
-                          (= (:block/type d) "property")
+                          (sqlite-util/property? d)
                           :property
-                          (= (:block/type d) "tag")
+                          (sqlite-util/tag? d)
                           :class
-                          (= (:block/type d) "hidden")
+                          (sqlite-util/hidden? d)
                           :hidden
-                          (= (:block/type d) "whiteboard")
+                          (sqlite-util/whiteboard? d)
                           :normal-page
                           (sqlite-util/page? d)
                           :normal-page

+ 1 - 1
deps/db/src/logseq/db/sqlite/common_db.cljs

@@ -143,7 +143,7 @@
                              id))
         page? (sqlite-util/page? block)
         get-children (fn [block children page?]
-                       (let [long-page? (and (> (count children) 500) (not (= (:block/type block) "whiteboard")))]
+                       (let [long-page? (and (> (count children) 500) (not (sqlite-util/whiteboard? block)))]
                          (if long-page?
                            (->> (map (fn [e]
                                        (select-keys e [:db/id :block/uuid :block/page :block/order :block/parent :block/collapsed? :block/link]))

+ 28 - 0
deps/db/src/logseq/db/sqlite/util.cljs

@@ -8,6 +8,7 @@
             [datascript.transit :as dt]
             [logseq.common.util :as common-util]
             [logseq.common.uuid :as common-uuid]
+            [logseq.common.config :as common-config]
             [logseq.db.frontend.order :as db-order]
             [logseq.db.frontend.property :as db-property]
             [logseq.db.frontend.property.type :as db-property-type]
@@ -131,3 +132,30 @@
   [block]
   (contains? #{"page" "journal" "whiteboard" "tag" "property" "hidden"}
              (:block/type block)))
+
+(defn tag?
+  [entity]
+  (= (:block/type entity) "tag"))
+(defn property?
+  [entity]
+  (= (:block/type entity) "property"))
+(defn closed-value?
+  [entity]
+  (= (:block/type entity) "closed value"))
+(defn whiteboard?
+  "Given a page entity or map, check if it is a whiteboard page"
+  [page]
+  (= (:block/type page) "whiteboard"))
+
+(defn journal?
+  "Given a page entity or map, check if it is a journal page"
+  [page]
+  (= (:block/type page) "journal"))
+
+(defn hidden?
+  [page]
+  (when page
+    (if (string? page)
+      (or (string/starts-with? page "$$$")
+          (= common-config/favorites-page-name page))
+      (= (:block/type page) "hidden"))))

+ 4 - 4
deps/db/test/logseq/db/sqlite/create_graph_test.cljs

@@ -7,7 +7,8 @@
             [logseq.db.sqlite.create-graph :as sqlite-create-graph]
             [logseq.db.frontend.validate :as db-validate]
             [logseq.db.frontend.property :as db-property]
-            [logseq.db.sqlite.build :as sqlite-build]))
+            [logseq.db.sqlite.build :as sqlite-build]
+            [logseq.db :as ldb]))
 
 (deftest new-graph-db-idents
   (testing "a new graph follows :db/ident conventions for"
@@ -60,12 +61,11 @@
   (let [conn (d/create-conn db-schema/schema-for-db-based-graph)
         _ (d/transact! conn (sqlite-create-graph/build-db-initial-data "{}"))
         task (d/entity @conn :logseq.class/Task)]
-    (is (= (:block/type task) "tag")
+    (is (ldb/tag? task)
         "Task class has correct type")
     (is (= 3 (count (:class/schema.properties task)))
         "Has correct number of task properties")
-    (is (every? #(= (:block/type %) "property")
-                (:class/schema.properties task))
+    (is (every? ldb/property? (:class/schema.properties task))
         "Each task property has correct type")))
 
 (deftest new-graph-is-valid

+ 2 - 2
deps/graph-parser/src/logseq/graph_parser/exporter.cljs

@@ -263,7 +263,7 @@
   (let [prop-type (cond (and (coll? prop-val)
                              (seq prop-val)
                              (set/subset? prop-val
-                                          (set (keep #(when (= (:block/type %) "journal")
+                                          (set (keep #(when (ldb/journal? %)
                                                         (:block/title %)) refs))))
                         :date
                         (and (coll? prop-val) (seq prop-val) (text-with-refs? prop-val prop-val-text))
@@ -890,7 +890,7 @@
         {:keys [pages-tx page-properties-tx page-names-to-uuids existing-pages]} (build-pages-tx conn pages blocks tx-options)
         whiteboard-pages (->> pages-tx
                               ;; support old and new whiteboards
-                              (filter #(= (:block/type %) "whiteboard"))
+                              (filter ldb/whiteboard?)
                               (map (fn [page-block]
                                      (-> page-block
                                          (assoc :block/format :markdown

+ 2 - 2
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs

@@ -377,7 +377,7 @@
             "tagged block tag converts tag to page ref")
         (is (= [(:db/id tag-page)] (map :db/id (:block/refs block)))
             "tagged block has correct refs")
-        (is (and tag-page (not (= (:block/type tag-page) "tag")))
+        (is (and tag-page (not (ldb/tag? tag-page)))
             "tag page is not a class")
 
         (is (= {:logseq.property/page-tags #{"Movie"}}
@@ -408,7 +408,7 @@
 
       (is (= "tag" (:block/type tag-page))
           "configured tag page in :tag-classes is a class")
-      (is (and another-tag-page (not= (:block/type another-tag-page) "tag"))
+      (is (and another-tag-page (not (ldb/tag? another-tag-page)))
           "unconfigured tag page is not a class")
 
       (is (= {:block/tags [:user.class/Movie]}

+ 3 - 2
deps/graph-parser/test/logseq/graph_parser/extract_test.cljs

@@ -2,7 +2,8 @@
   (:require [cljs.test :refer [deftest is are]]
             [logseq.graph-parser.extract :as extract]
             [datascript.core :as d]
-            [logseq.db.frontend.schema :as db-schema]))
+            [logseq.db.frontend.schema :as db-schema]
+            [logseq.db :as ldb]))
 
 ;; This is a copy of frontend.util.fs/multiplatform-reserved-chars for reserved chars testing
 (def multiplatform-reserved-chars ":\\*\\?\"<>|\\#\\\\")
@@ -144,6 +145,6 @@
         page (first pages)]
     (is (= (get-in page [:block/file :file/path]) "/whiteboards/foo.edn"))
     (is (= (:block/name page) "foo"))
-    (is (= (:block/type page) "whiteboard"))
+    (is (ldb/whiteboard? page))
     (is (= (:block/title page) "Foo"))
     (is (every? #(= (:block/parent %) [:block/uuid #uuid "a846e3b4-c41d-4251-80e1-be6978c36d8c"]) blocks))))

+ 4 - 4
deps/outliner/src/logseq/outliner/property.cljs

@@ -335,7 +335,7 @@
 
 (defn ^:api get-class-parents
   [tags]
-  (let [tags' (filter (fn [tag] (= (:block/type tag) "tag")) tags)]
+  (let [tags' (filter ldb/tag? tags)]
     (set (mapcat ldb/get-class-parents tags'))))
 
 (defn ^:api get-class-properties
@@ -351,7 +351,7 @@
   (let [block (d/entity db eid)
         classes (->> (:block/tags block)
                      (sort-by :block/name)
-                     (filter (fn [tag] (= (:block/type tag) "tag"))))
+                     (filter ldb/tag?))
         class-parents (get-class-parents classes)
         all-classes (->> (concat classes class-parents)
                          (filter (fn [class]
@@ -522,7 +522,7 @@
 (defn class-add-property!
   [conn class-id property-id]
   (when-let [class (d/entity @conn class-id)]
-    (if (= (:block/type class) "tag")
+    (if (ldb/tag? class)
       (ldb/transact! conn
                      [[:db/add (:db/id class) :class/schema.properties property-id]]
                      {:outliner-op :save-block})
@@ -532,7 +532,7 @@
 (defn class-remove-property!
   [conn class-id property-id]
   (when-let [class (d/entity @conn class-id)]
-    (when (= (:block/type class) "tag")
+    (when (ldb/tag? class)
       (when-let [property (d/entity @conn property-id)]
         (when-not (ldb/built-in-class-property? class property)
           (ldb/transact! conn [[:db/retract (:db/id class) :class/schema.properties property-id]]

+ 2 - 2
src/main/frontend/components/cmdk/core.cljs

@@ -223,11 +223,11 @@
   (let [entity (db/entity [:block/uuid (:block/uuid page)])
         source-page (model/get-alias-source-page repo (:db/id entity))
         icon (cond
-               (ldb/class? entity)
+               (ldb/tag? entity)
                "hash"
                (ldb/property? entity)
                "letter-p"
-               (ldb/whiteboard-page? entity)
+               (ldb/whiteboard? entity)
                "whiteboard"
                :else
                "page")]

+ 5 - 5
src/main/frontend/components/db_based/page.cljs

@@ -13,7 +13,8 @@
             [logseq.shui.ui :as shui]
             [frontend.util :as util]
             [clojure.string :as string]
-            [logseq.db.frontend.property :as db-property]))
+            [logseq.db.frontend.property :as db-property]
+            [logseq.db :as ldb]))
 
 (rum/defc page-properties
   "This component is called by page-inner and within configure/info modal. This should not
@@ -51,9 +52,8 @@
   [state page *mode]
   (let [*mode *mode
         mode (rum/react *mode)
-        type (:block/type page)
-        class? (= type "tag")
-        property? (= type "property")
+        class? (ldb/tag? page)
+        property? (ldb/property? page)
         page-opts {:configure? true}]
     (when (nil? mode)
       (reset! *mode (cond
@@ -106,7 +106,7 @@
         *hover? (::hover? state)
         *mode (::mode state)
         type (:block/type page)
-        class? (= type "tag")
+        class? (ldb/tag? page)
         collapsed? (not @*show-info?)
         has-properties? (or
                          (seq (:block/tags page))

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

@@ -172,7 +172,7 @@
                        [:div.flex.flex-row.items-center.gap-1
                         (when-not db-tag?
                           (cond
-                            (ldb/class? block)
+                            (ldb/tag? block)
                             [:div (ui/icon "hash" {:size 14})]
                             (ldb/property? block)
                             [:div (ui/icon "letter-p" {:size 14})]

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

@@ -32,7 +32,7 @@
 (defn get-node-icon
   [node-entity opts]
   (let [default-icon-id (cond
-                          (ldb/class? node-entity)
+                          (ldb/tag? node-entity)
                           "hash"
                           (ldb/property? node-entity)
                           "letter-p"

+ 4 - 3
src/main/frontend/components/imports.cljs

@@ -29,7 +29,8 @@
             [rum.core :as rum]
             [logseq.shui.ui :as shui]
             [lambdaisland.glogi :as log]
-            [logseq.db.frontend.validate :as db-validate]))
+            [logseq.db.frontend.validate :as db-validate]
+            [logseq.db :as ldb]))
 
 ;; Can't name this component as `frontend.components.import` since shadow-cljs
 ;; will complain about it.
@@ -238,9 +239,9 @@
   {:entities (count entities)
    :pages (count (filter :block/name entities))
    :blocks (count (filter :block/title entities))
-   :classes (count (filter #(= (:block/type %) "tag") entities))
+   :classes (count (filter ldb/tag? entities))
    :objects (count (filter #(seq (:block/tags %)) entities))
-   :properties (count (filter #(= (:block/type %) "property") entities))
+   :properties (count (filter ldb/property? entities))
    :property-values (count (mapcat :block/properties entities))})
 
 (defn- validate-imported-data

+ 6 - 6
src/main/frontend/components/page.cljs

@@ -333,10 +333,10 @@
       (when title
         (let [repo (state/get-current-repo)
               db-based? (config/db-based-graph? repo)
-              journal? (ldb/journal-page? page)
+              journal? (ldb/journal? page)
               icon (or (get page (pu/get-pid :logseq.property/icon))
                        (when db-based?
-                         (or (when (ldb/class? page)
+                         (or (when (ldb/tag? page)
                                {:type :tabler-icon
                                 :id "hash"})
                              (when (ldb/property? page)
@@ -557,14 +557,14 @@
             (cond
               (and db-based? (not block?))
               (db-page/page-info page
-                                 (if (and (ldb/class? page) sidebar?)
+                                 (if (and (ldb/tag? page) sidebar?)
                                    (atom true)
                                    (::show-page-info? state)))
 
               (and (not db-based?) (not block?))
               [:div.pb-2])
 
-            (when (and db-based? (ldb/class? page))
+            (when (and db-based? (ldb/tag? page))
               [:div.mt-8
                (objects/class-objects page)])
 
@@ -572,7 +572,7 @@
               [:div.mt-8
                (objects/property-related-objects page)])
 
-            (when-not (and db-based? (or (ldb/class? page) (ldb/property? page)))
+            (when-not (and db-based? (or (ldb/tag? page) (ldb/property? page)))
               [:div
                (when (and block? (not sidebar?) (not whiteboard?))
                  (let [config (merge config {:id "block-parent"
@@ -595,7 +595,7 @@
             (when (and (not block?) (not db-based?))
               (tagged-pages repo page page-title))
 
-            (when (= (:block/type page) "tag")
+            (when (ldb/tag? page)
               (class-component/class-children page))
 
             ;; referenced blocks

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

@@ -3,6 +3,7 @@
             [frontend.components.export :as export]
             [frontend.context.i18n :refer [t]]
             [frontend.db :as db]
+            [logseq.db :as ldb]
             [frontend.handler.notification :as notification]
             [frontend.handler.page :as page-handler]
             [frontend.handler.common.developer :as dev-common-handler]
@@ -49,7 +50,7 @@
   (when-let [page-name (and page (db/page? page) (:block/name page))]
     (let [repo (state/sub :git/current-repo)
           page-title (:block/title page)
-          whiteboard? (= (:block/type page) "whiteboard")
+          whiteboard? (ldb/whiteboard? page)
           block? (and page (util/uuid-string? page-name) (not whiteboard?))
           contents? (= page-name "contents")
           public? (pu/get-block-property-value page :logseq.property/public)

+ 6 - 5
src/main/frontend/components/property.cljs

@@ -33,7 +33,8 @@
             [logseq.db.frontend.order :as db-order]
             [logseq.outliner.core :as outliner-core]
             [dommy.core :as d]
-            [frontend.mixins :as mixins]))
+            [frontend.mixins :as mixins]
+            [logseq.db :as ldb]))
 
 (defn- <create-class-if-not-exists!
   [value]
@@ -112,7 +113,7 @@
 
 (defn- handle-delete-property!
   [block property & {:keys [class? class-schema?]}]
-  (let [class? (or class? (= (:block/type block) "tag"))
+  (let [class? (or class? (ldb/tag? block))
         remove! #(let [repo (state/get-current-repo)]
                    (if (and class? class-schema?)
                      (db-property-handler/class-remove-property! (:db/id block) (:db/id property))
@@ -130,7 +131,7 @@
   [entity property-uuid-or-name schema {:keys [class-schema? page-configure?]}]
   (p/let [repo (state/get-current-repo)
           ;; Both conditions necessary so that a class can add its own page properties
-          add-class-property? (and (= (:block/type entity) "tag") page-configure? class-schema?)
+          add-class-property? (and (ldb/tag? entity) page-configure? class-schema?)
           result (when (uuid? property-uuid-or-name)
                    (db-async/<get-block repo property-uuid-or-name {:children? false}))
           ;; In block context result is in :block
@@ -192,7 +193,7 @@
                 (reset! *show-new-property-config? :adding-property))
               (p/let [property' (when block (<add-property-from-dropdown block property-name schema opts))
                       property (or property' property)
-                      add-class-property? (and (= (:block/type block) "tag") page-configure? class-schema?)]
+                      add-class-property? (and (ldb/tag? block) page-configure? class-schema?)]
                 (when *property (reset! *property property))
                 (p/do!
                  (when *show-new-property-config? (reset! *show-new-property-config? false))
@@ -471,7 +472,7 @@
         (reset! *show-new-property-config? true))
       (reset! *property property)
       (when property
-        (let [add-class-property? (and (= (:block/type block) "tag") class-schema?)
+        (let [add-class-property? (and (ldb/tag? block) class-schema?)
               type (get-in property [:block/schema :type])]
           (cond
             add-class-property?

+ 3 - 3
src/main/frontend/components/property/value.cljs

@@ -101,7 +101,7 @@
   ([block property-id property-value' {:keys [exit-edit? class-schema?]
                                        :or {exit-edit? true}}]
    (let [repo (state/get-current-repo)
-         class? (= (:block/type block) "tag")
+         class? (ldb/tag? block)
          property (db/entity property-id)
          many? (db-property/many? property)
          checkbox? (= :checkbox (get-in property [:block/schema :type]))]
@@ -313,7 +313,7 @@
 (defn- get-node-icon
   [node]
   (cond
-    (ldb/class? node)
+    (ldb/tag? node)
     "hash"
     (ldb/property? node)
     "letter-p"
@@ -569,7 +569,7 @@
     (if (state/sub-async-query-loading value)
       [:div.text-sm.opacity-70 "loading"]
       (if-let [v-block (db/sub-block (:db/id value))]
-        (let [class? (= (:block/type v-block) "tag")
+        (let [class? (ldb/tag? v-block)
               invalid-warning [:div.warning.text-sm
                                "Invalid block value, please delete the current property."]]
           (when v-block

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

@@ -62,7 +62,7 @@
   [page-entity *filters total filter-n filtered-ref-blocks *ref-pages]
   (let [filters @*filters
         threshold (state/get-linked-references-collapsed-threshold)
-        default-collapsed? (or (>= total threshold) (ldb/class? page-entity))
+        default-collapsed? (or (>= total threshold) (ldb/tag? page-entity))
         *collapsed? (atom nil)]
     (ui/foldable
      [:div.flex.flex-row.flex-1.justify-between.items-center

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

@@ -102,7 +102,7 @@
         [[:.flex.items-center.page-title
           (if-let [icon (pu/get-block-property-value page :logseq.property/icon)]
             [:.text-md.mr-2 icon]
-            (ui/icon (if (= (:block/type page) "whiteboard") "whiteboard" "page") {:class "text-md mr-2"}))
+            (ui/icon (if (ldb/whiteboard? page) "whiteboard" "page") {:class "text-md mr-2"}))
           [: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)))

+ 5 - 5
src/main/frontend/db/model.cljs

@@ -26,7 +26,7 @@
 
 (def block-attrs ldb/block-attrs)
 
-(def hidden-page? ldb/hidden-page?)
+(def hidden-page? ldb/hidden?)
 
 (defn get-all-tagged-pages
   [repo]
@@ -571,7 +571,7 @@ independent of format as format specific heading characters are stripped"
                                react)]
       (->> mentioned-pages
            (keep (fn [page]
-                   (when-not (and (not include-journals?) (ldb/journal-page? page))
+                   (when-not (and (not include-journals?) (ldb/journal? page))
                      page)))
            (mapv (fn [page]
                    [(:block/name page) (get-page-alias-names repo (:db/id page))]))))))
@@ -635,7 +635,7 @@ independent of format as format specific heading characters are stripped"
                      (= (:db/id (:block/link block)) eid)
                      (= (:db/id block) eid)
                      (= eid (:db/id (:block/page block)))
-                     (ldb/hidden-page? (:block/page block))
+                     (ldb/hidden? (:block/page block))
                      (contains? (set (map :db/id (:block/tags block))) (:db/id entity)))))
           (util/distinct-by :db/id)))))))
 
@@ -652,7 +652,7 @@ independent of format as format specific heading characters are stripped"
 (defn journal-page?
   "sanitized page-name only"
   [page-name]
-  (ldb/journal-page? (ldb/get-page (conn/get-db) page-name)))
+  (ldb/journal? (ldb/get-page (conn/get-db) page-name)))
 
 (defn get-classes-with-property
   "Get classes which have given property as a class property"
@@ -706,7 +706,7 @@ independent of format as format specific heading characters are stripped"
   (let [page (if (string? page)
                (get-page page)
                page)]
-    (ldb/whiteboard-page? page)))
+    (ldb/whiteboard? page)))
 
 (comment
   (defn get-orphaned-pages

+ 1 - 1
src/main/frontend/extensions/slide.cljs

@@ -106,7 +106,7 @@
   [page]
   (let [page-name (:block/title page)
         loading? (rum/react *loading?)
-        journal? (ldb/journal-page? page)
+        journal? (ldb/journal? page)
         repo (state/get-current-repo)
         blocks (-> (db/get-page-blocks-no-cache repo (:db/id page))
                    (outliner-tree/blocks->vec-tree (:db/id page)))

+ 2 - 2
src/main/frontend/handler/db_based/recent.cljs

@@ -9,7 +9,7 @@
   (assert db-id (number? db-id))
   (when-not (:db/restoring? @state/state)
     (when-let [page (db/entity db-id)]
-      (when-not (ldb/hidden-page? page)
+      (when-not (ldb/hidden? page)
         (let [pages (state/get-recent-pages)]
           (when (or (and click-from-recent? (not ((set pages) db-id)))
                     (not click-from-recent?))
@@ -23,4 +23,4 @@
        (take 20)
        (keep db/entity)
        (filter db/page?)
-       (remove ldb/hidden-page?)))
+       (remove ldb/hidden?)))

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

@@ -1310,8 +1310,7 @@
 (defn save-block-aux!
   [block value opts]
   (let [entity (db/entity [:block/uuid (:block/uuid block)])]
-    (when (and (:db/id entity)
-               (not (= (:block/type entity) "property")))
+    (when (and (:db/id entity) (not (ldb/property? entity)))
       (let [value (string/trim value)]
         ;; FIXME: somehow frontend.components.editor's will-unmount event will loop forever
         ;; maybe we shouldn't save the block/file in "will-unmount" event?
@@ -2171,7 +2170,7 @@
                                             {:children? true
                                              :nested-children? true}))]
          (when (:db/id block)
-           (let [journal? (ldb/journal-page? target)
+           (let [journal? (ldb/journal? target)
                  target (or target (state/get-edit-block))
                  format (:block/format block)
                  block-uuid (:block/uuid block)

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

@@ -110,7 +110,7 @@
               created-at-filter
               (filter #(<= (:block/created-at %) (+ (apply min created-ats) created-at-filter)))
               (not journal?)
-              (remove ldb/journal-page?)
+              (remove ldb/journal?)
               (not excluded-pages?)
               (remove (fn [p] (true? (pu/get-block-property-value p :logseq.property/exclude-from-graph-view)))))
             links (concat (seq relation)

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

@@ -247,7 +247,7 @@
   (let [graph-specific-hidden?
         (if (config/db-based-graph? repo)
           (fn [p]
-            (and (= (:block/type p) "property") (ldb/built-in? p)))
+            (and (ldb/property? p) (ldb/built-in? p)))
           (fn [p]
             (gp-db/built-in-pages-names (string/upper-case (:block/name p)))))]
     (->> (db/get-all-pages repo)
@@ -341,7 +341,7 @@
         (let [chosen (:block/title chosen-result)
               class? (and db-based? hashtag?
                           (or (string/includes? chosen (str (t :new-tag) " "))
-                              (ldb/class? (db/get-page chosen))))
+                              (ldb/tag? (db/get-page chosen))))
               chosen (-> chosen
                          (string/replace-first (str (t :new-tag) " ") "")
                          (string/replace-first (str (t :new-page) " ") ""))

+ 1 - 1
src/main/frontend/routes.cljs

@@ -42,7 +42,7 @@
     {:name :page
      :view (fn [route-match]
              (let [page-name (get-in route-match [:parameters :path :name])
-                   whiteboard? (ldb/whiteboard-page? (db/get-page page-name))]
+                   whiteboard? (ldb/whiteboard? (db/get-page page-name))]
                (if whiteboard?
                  (whiteboard/whiteboard-route route-match)
                  (page/page route-match))))}]

+ 1 - 1
src/main/frontend/worker/export.cljs

@@ -39,7 +39,7 @@
               [?b :block/name]] db)
 
        (map (fn [[page]]
-              (let [whiteboard? (= (:block/type page) "whiteboard")
+              (let [whiteboard? (ldb/whiteboard? page)
                     blocks (ldb/get-page-blocks db (:db/id page))
                     blocks' (if whiteboard?
                               blocks

+ 1 - 1
src/main/frontend/worker/file.cljs

@@ -61,7 +61,7 @@
   [repo conn page-db-id outliner-op context request-id]
   (let [page-block (d/pull @conn '[*] page-db-id)
         page-db-id (:db/id page-block)
-        whiteboard? (= (:block/type page-block) "whiteboard")
+        whiteboard? (ldb/whiteboard? page-block)
         blocks-count (ldb/get-page-blocks-count @conn page-db-id)
         blocks-just-deleted? (and (zero? blocks-count)
                                   (contains? #{:delete-blocks :move-blocks} outliner-op))]

+ 2 - 2
src/main/frontend/worker/file/core.cljs

@@ -134,7 +134,7 @@
     (let [format (name (get page-block :block/format (:preferred-format context)))
           date-formatter (:date-formatter context)
           title (string/capitalize (:block/name page-block))
-          whiteboard-page? (ldb/whiteboard-page? page-block)
+          whiteboard-page? (ldb/whiteboard? page-block)
           format (if whiteboard-page? "edn" format)
           journal-page? (worker-date/valid-journal-title? title date-formatter)
           journal-title (worker-date/normalize-journal-title title date-formatter)
@@ -164,7 +164,7 @@
         file-db-id (-> page-block :block/file :db/id)
         file-path (-> (d/entity db file-db-id) :file/path)
         result (if (and (string? file-path) (not-empty file-path))
-                 (let [new-content (if (= (:block/type page-block) "whiteboard")
+                 (let [new-content (if (ldb/whiteboard? page-block)
                                      (->
                                       (wfu/ugly-pr-str {:blocks tree
                                                         :pages (list (remove-transit-ids page-block))})

+ 1 - 1
src/main/frontend/worker/handler/page.cljs

@@ -75,7 +75,7 @@
                                      blocks)
             db-based? (sqlite-util/db-based-graph? repo)]
         ;; TODO: maybe we should add $$$favorites to built-in pages?
-        (if (or (ldb/built-in? page) (= (:block/type page) "hidden"))
+        (if (or (ldb/built-in? page) (ldb/hidden? page))
           (do
             (error-handler {:msg "Built-in page cannot be deleted"})
             false)

+ 4 - 4
src/main/frontend/worker/handler/page/file_based/rename.cljs

@@ -207,7 +207,7 @@
   [db old-page-name new-page-name]
   (let [page (d/entity db [:block/name old-page-name])
         file (:block/file page)]
-    (when (and file (not (ldb/journal-page? page)))
+    (when (and file (not (ldb/journal? page)))
       (let [old-path (:file/path file)
             new-file-name (wfu/file-name-sanity new-page-name) ;; w/o file extension
             new-path (compute-new-file-path old-path new-file-name)]
@@ -302,7 +302,7 @@
 
 (defn rename!
   [repo conn config page-uuid new-name & {:keys [persist-op?]
-                                         :or {persist-op? true}}]
+                                          :or {persist-op? true}}]
   (let [db @conn
         page-e        (d/entity db [:block/uuid page-uuid])
         old-name      (:block/title page-e)
@@ -319,8 +319,8 @@
       :invalid-empty-name
 
       (and page-e new-page-e
-           (or (= (:block/type page-e) "whiteboard")
-               (= (:block/type new-page-e) "whiteboard")))
+           (or (ldb/whiteboard? page-e)
+               (ldb/whiteboard? new-page-e)))
       :merge-whiteboard-pages
 
       (and old-name new-name name-changed?)

+ 3 - 3
src/main/frontend/worker/rtc/remote_update.cljs

@@ -135,7 +135,7 @@
   (group-by (fn [{:keys [block-uuid]}]
               (boolean
                (when-let [block (d/entity db [:block/uuid block-uuid])]
-                 (ldb/whiteboard-page? (:block/parent block)))))
+                 (ldb/whiteboard? (:block/parent block)))))
             remote-remove-ops))
 
 (defn- apply-remote-remove-ops-helper
@@ -182,7 +182,7 @@
   (when (seq remote-parents)
     (let [first-remote-parent (first remote-parents)
           local-parent (d/entity @conn [:block/uuid first-remote-parent])
-          whiteboard-page-block? (ldb/whiteboard-page? local-parent)
+          whiteboard-page-block? (ldb/whiteboard? local-parent)
           b (d/entity @conn [:block/uuid block-uuid])]
       (case [whiteboard-page-block? (some? local-parent) (some? remote-block-order)]
         [false true true]
@@ -455,7 +455,7 @@
       (let [{update-block-order-tx-data :tx-data op-value :op-value} (update-block-order (:db/id ent) op-value)
             first-remote-parent (first parents)
             local-parent (d/entity @conn [:block/uuid first-remote-parent])
-            whiteboard-page-block? (ldb/whiteboard-page? local-parent)]
+            whiteboard-page-block? (ldb/whiteboard? local-parent)]
         (if whiteboard-page-block?
           (upsert-whiteboard-block repo conn op-value)
           (do (when-let [schema-tx-data (remote-op-value->schema-tx-data block-uuid op-value)]

+ 4 - 11
src/main/frontend/worker/search.cljs

@@ -175,17 +175,10 @@ DROP TRIGGER IF EXISTS blocks_au;
       (seq (worker-util/search-normalize match true))
       (seq (worker-util/search-normalize q true))))))
 
-(defn- hidden-page?
-  [page]
-  (when page
-    (if (string? page)
-      (string/starts-with? page "$$$")
-      (= (:block/type page) "hidden"))))
-
 (defn- page-or-object?
   [entity]
   (and (or (ldb/page? entity) (seq (:block/tags entity)))
-       (not (hidden-page? entity))))
+       (not (ldb/hidden? entity))))
 
 (defn get-all-fuzzy-supported-blocks
   "Only pages and objects are supported now."
@@ -196,7 +189,7 @@ DROP TRIGGER IF EXISTS blocks_au;
                         (map :e))
         blocks (->> (distinct (concat page-ids object-ids))
                     (map #(d/entity db %)))]
-    (remove hidden-page? blocks)))
+    (remove ldb/hidden? blocks)))
 
 (defn- sanitize
   [content]
@@ -384,10 +377,10 @@ DROP TRIGGER IF EXISTS blocks_au;
                                blocks-to-add-set)]
       {:blocks-to-remove     (->>
                               (keep #(d/entity db-before %) blocks-to-remove-set)
-                              (remove hidden-page?))
+                              (remove ldb/hidden?))
        :blocks-to-add        (->>
                               (keep #(d/entity db-after %) blocks-to-add-set')
-                              (remove hidden-page?))})))
+                              (remove ldb/hidden?))})))
 
 (defn- get-affected-blocks
   [repo tx-report]

+ 1 - 1
src/main/logseq/api.cljs

@@ -601,7 +601,7 @@
         (->>
           (d/datoms db :avet :block/name)
           (map #(db-utils/pull (:e %)))
-          (remove ldb/hidden-page?)
+          (remove ldb/hidden?)
           (remove (fn [page]
                     (common-util/uuid-string? (:block/name page)))))
         (sdk-utils/normalize-keyword-for-json)