Browse Source

refactor: update :block/type to cardinality one instead of many

Tienson Qin 1 year ago
parent
commit
d26e620a82
47 changed files with 243 additions and 261 deletions
  1. 2 2
      deps/db/script/validate_client_db.cljs
  2. 11 11
      deps/db/src/logseq/db.cljs
  3. 6 13
      deps/db/src/logseq/db/frontend/malli_schema.cljs
  4. 1 1
      deps/db/src/logseq/db/frontend/property/build.cljs
  5. 1 1
      deps/db/src/logseq/db/frontend/property/type.cljs
  6. 1 2
      deps/db/src/logseq/db/frontend/schema.cljs
  7. 2 2
      deps/db/src/logseq/db/sqlite/build.cljs
  8. 1 1
      deps/db/src/logseq/db/sqlite/common_db.cljs
  9. 2 2
      deps/db/src/logseq/db/sqlite/create_graph.cljs
  10. 5 4
      deps/db/src/logseq/db/sqlite/util.cljs
  11. 2 2
      deps/db/test/logseq/db/sqlite/build_test.cljs
  12. 3 3
      deps/db/test/logseq/db/sqlite/create_graph_test.cljs
  13. 3 7
      deps/graph-parser/src/logseq/graph_parser/block.cljs
  14. 3 4
      deps/graph-parser/src/logseq/graph_parser/exporter.cljs
  15. 3 3
      deps/graph-parser/src/logseq/graph_parser/extract.cljc
  16. 5 5
      deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs
  17. 1 1
      deps/graph-parser/test/logseq/graph_parser/extract_test.cljs
  18. 1 1
      deps/graph-parser/test/logseq/graph_parser_test.cljs
  19. 0 0
      deps/graph-parser/test/resources/exporter-test-graph/whiteboards/Test Whiteboard.edn
  20. 125 127
      deps/graph-parser/test/resources/exporter-test-graph/whiteboards/block tests.edn
  21. 1 1
      deps/graph-parser/test/resources/exporter-test-graph/whiteboards/publishing test.edn
  22. 4 4
      deps/outliner/src/logseq/outliner/property.cljs
  23. 1 1
      src/main/frontend/common_keywords.cljs
  24. 2 2
      src/main/frontend/components/all_pages.cljs
  25. 11 11
      src/main/frontend/components/db_based/page.cljs
  26. 2 2
      src/main/frontend/components/imports.cljs
  27. 1 1
      src/main/frontend/components/page.cljs
  28. 1 1
      src/main/frontend/components/page_menu.cljs
  29. 4 4
      src/main/frontend/components/property.cljs
  30. 2 2
      src/main/frontend/components/property/value.cljs
  31. 1 1
      src/main/frontend/components/right_sidebar.cljs
  32. 1 1
      src/main/frontend/handler/editor.cljs
  33. 7 7
      src/main/frontend/handler/page.cljs
  34. 3 3
      src/main/frontend/handler/whiteboard.cljs
  35. 5 3
      src/main/frontend/worker/db/migrate.cljs
  36. 1 1
      src/main/frontend/worker/export.cljs
  37. 1 1
      src/main/frontend/worker/file.cljs
  38. 1 1
      src/main/frontend/worker/file/core.cljs
  39. 1 1
      src/main/frontend/worker/handler/page.cljs
  40. 1 2
      src/main/frontend/worker/handler/page/db_based/page.cljs
  41. 1 1
      src/main/frontend/worker/handler/page/file_based/page.cljs
  42. 2 2
      src/main/frontend/worker/handler/page/file_based/rename.cljs
  43. 1 1
      src/main/frontend/worker/rtc/asset_db_listener.cljs
  44. 3 4
      src/main/frontend/worker/rtc/db_listener.cljs
  45. 3 7
      src/main/frontend/worker/rtc/remote_update.cljs
  46. 2 2
      src/main/frontend/worker/search.cljs
  47. 2 2
      src/test/frontend/worker/rtc/client_test.cljs

+ 2 - 2
deps/db/script/validate_client_db.cljs

@@ -81,9 +81,9 @@
                                (count ent-maps) " entities, "
                                (count (filter :block/name ent-maps)) " pages, "
                                (count (filter :block/title ent-maps)) " blocks, "
-                               (count (filter #(contains? (:block/type %) "class") ent-maps)) " classes, "
+                               (count (filter #(= (:block/type %) "class") ent-maps)) " classes, "
                                (count (filter #(seq (:block/tags %)) ent-maps)) " objects, "
-                               (count (filter #(contains? (:block/type %) "property") ent-maps)) " properties and "
+                               (count (filter #(= (:block/type %) "property") ent-maps)) " properties and "
                                (count (mapcat db-property/properties ent-maps)) " property pairs"))
     (validate-client-db @conn ent-maps options)))
 

+ 11 - 11
deps/db/src/logseq/db.cljs

@@ -103,12 +103,12 @@
 (defn whiteboard-page?
   "Given a page entity or map, check if it is a whiteboard page"
   [page]
-  (contains? (set (:block/type page)) "whiteboard"))
+  (= (:block/type page) "whiteboard"))
 
 (defn journal-page?
   "Given a page entity or map, check if it is a journal page"
   [page]
-  (contains? (set (:block/type page)) "journal"))
+  (= (:block/type page) "journal"))
 
 (defn get-page-blocks
   "Return blocks of the designated page, without using cache.
@@ -171,7 +171,7 @@
     (if (string? page)
       (or (string/starts-with? page "$$$")
           (= common-config/favorites-page-name page))
-      (contains? (set (:block/type page)) "hidden"))))
+      (= (:block/type page) "hidden"))))
 
 (defn get-pages
   [db]
@@ -249,7 +249,7 @@
                                 (not (contains? built-in-pages name))
                                 (not (whiteboard-page? page))
                                 (not (:block/_namespace page))
-                                (not (contains? (:block/type page) "property"))
+                                (not (= (:block/type page) "property"))
                                  ;; 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))))
@@ -448,7 +448,7 @@
   "Whether property a built-in property for the specific class"
   [class-entity property-entity]
   (and (built-in? class-entity)
-       (contains? (:block/type class-entity) "class")
+       (= (:block/type class-entity) "class")
        (built-in? property-entity)
        (contains? (set (map :db/ident (:class/schema.properties class-entity)))
                   (:db/ident property-entity))))
@@ -466,7 +466,7 @@
      {:block/uuid (common-uuid/gen-uuid)
       :block/name common-config/favorites-page-name
       :block/title common-config/favorites-page-name
-      :block/type #{"page" "hidden"}
+      :block/type "hidden"
       :block/format :markdown})]))
 
 (defn build-favorite-tx
@@ -486,7 +486,7 @@
        {:block/uuid page-id
         :block/name common-config/views-page-name
         :block/title common-config/views-page-name
-        :block/type #{"page" "hidden"}
+        :block/type "hidden"
         :block/format :markdown})
       (sqlite-util/block-with-timestamps
        {:block/uuid (common-uuid/gen-uuid)
@@ -506,13 +506,13 @@
 (def page? sqlite-util/page?)
 (defn class?
   [entity]
-  (contains? (:block/type entity) "class"))
+  (= (:block/type entity) "class"))
 (defn property?
   [entity]
-  (contains? (:block/type entity) "property"))
+  (= (:block/type entity) "property"))
 (defn closed-value?
   [entity]
-  (contains? (:block/type entity) "closed value"))
+  (= (:block/type entity) "closed value"))
 
 (def db-based-graph? entity-plus/db-based-graph?)
 
@@ -562,7 +562,7 @@
       (loop [current-parent parent]
         (when (and
                current-parent
-               (contains? (:block/type parent) "class")
+               (= (:block/type parent) "class")
                (not (contains? @*classes (:db/id parent))))
           (swap! *classes conj (:db/id current-parent))
           (recur (:class/parent current-parent)))))

+ 6 - 13
deps/db/src/logseq/db/frontend/malli_schema.cljs

@@ -214,7 +214,7 @@
   "Common attributes for pages"
   [[:block/name :string]
    [:block/title :string]
-   [:block/type [:set [:enum "page" "class" "property" "whiteboard" "journal" "hidden"]]]
+   [:block/type [:enum "page" "class" "property" "whiteboard" "journal" "hidden"]]
    [:block/alias {:optional true} [:set :int]]
     ;; TODO: Should this be here or in common?
    [:block/path-refs {:optional true} [:set :int]]
@@ -366,7 +366,7 @@
   (vec
    (concat
     [:map]
-    [[:block/type [:= #{"closed value"}]]
+    [[:block/type [:= "closed value"]]
      ;; for built-in properties
      [:db/ident {:optional true} logseq-property-ident]
      [:block/title {:optional true} :string]
@@ -429,24 +429,17 @@
    [:db/ident [:= :logseq.property/empty-placeholder]]
    [:block/tx-id {:optional true} :int]])
 
-(defn- type-set
-  [d]
-  (when-let [type (:block/type d)]
-    (if (coll? type)
-      (set type)
-      #{type})))
-
 (def Data
   (into
    [:multi {:dispatch (fn [d]
                         (cond
-                          (contains? (type-set d) "property")
+                          (= (:block/type d) "property")
                           :property
-                          (contains? (type-set d) "class")
+                          (= (:block/type d) "class")
                           :class
-                          (contains? (type-set d) "hidden")
+                          (= (:block/type d) "hidden")
                           :hidden
-                          (contains? (type-set d) "whiteboard")
+                          (= (:block/type d) "whiteboard")
                           :normal-page
                           (sqlite-util/page? d)
                           :normal-page

+ 1 - 1
deps/db/src/logseq/db/frontend/property/build.cljs

@@ -8,7 +8,7 @@
 (defn- closed-value-new-block
   [block-id value property]
   (let [property-id (:db/ident property)]
-    (merge {:block/type #{"closed value"}
+    (merge {:block/type "closed value"
             :block/format :markdown
             :block/uuid block-id
             :block/page property-id

+ 1 - 1
deps/db/src/logseq/db/frontend/property/type.cljs

@@ -126,7 +126,7 @@
   [db val]
   (when-let [ent (d/entity db val)]
     (and (some? (:block/title ent))
-         (contains? (:block/type ent) "journal"))))
+         (= (:block/type ent) "journal"))))
 
 
 (def built-in-validation-schemas

+ 1 - 2
deps/db/src/logseq/db/frontend/schema.cljs

@@ -15,8 +15,7 @@
    ;; "macros" for macro
    ;; "property" for property blocks
    ;; "class" for structured page
-   :block/type {:db/index true
-                :db/cardinality :db.cardinality/many}
+   :block/type {:db/index true}
    :block/schema {}
    :block/uuid {:db/unique :db.unique/identity}
    :block/parent {:db/valueType :db.type/ref

+ 2 - 2
deps/db/src/logseq/db/sqlite/build.cljs

@@ -342,7 +342,7 @@
                       {:db/id (or (:db/id page) (new-db-id))
                        :block/title (or (:block/title page) (string/capitalize (:block/name page)))
                        :block/name (or (:block/name page) (common-util/page-name-sanity-lc (:block/title page)))
-                       :block/type #{"page"}
+                       :block/type "page"
                        :block/format :markdown}
                       (dissoc page :build/properties :db/id :block/name :block/title :build/tags))
             pvalue-tx-m (->property-value-tx-m new-page (:build/properties page) properties all-idents)]
@@ -465,7 +465,7 @@
                                                    :block/title page-name
                                                    :block/uuid
                                                    (common-uuid/gen-uuid :journal-page-uuid date-int)
-                                                   :block/type #{"journal" "page"}})))))
+                                                   :block/type "journal"})))))
                            m))]
     ;; Order matters as some steps depend on previous step having prepared blocks or pages in a certain way
     (->> pages-and-blocks

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

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

+ 2 - 2
deps/db/src/logseq/db/sqlite/create_graph.cljs

@@ -55,14 +55,14 @@
                    ;; Adding built-ins must come after initial properties and built-in-prop-value
                    [(mark-block-as-built-in' built-in-property)]
                    (map mark-block-as-built-in' properties)
-                   (keep #(when (= #{"closed value"} (:block/type %)) (mark-block-as-built-in' %))
+                   (keep #(when (= "closed value" (:block/type %)) (mark-block-as-built-in' %))
                          properties))]
     (doseq [m tx]
       (when-let [block-uuid (and (:db/ident m) (:block/uuid m))]
         (assert (string/starts-with? (str block-uuid) "00000002") m)))
 
     {:tx tx
-     :properties (filter #(contains? (:block/type %) "property") properties)
+     :properties (filter #(= (:block/type %) "property") properties)
      :built-in-prop-value built-in-prop-value}))
 
 (defn kv

+ 5 - 4
deps/db/src/logseq/db/sqlite/util.cljs

@@ -90,7 +90,7 @@
      (block-with-timestamps
       (cond->
        {:db/ident db-ident'
-        :block/type #{"property" "page"}
+        :block/type "property"
         :block/format :markdown
         :block/schema (merge {:type :default} (dissoc prop-schema :classes :cardinality))
         :block/name (common-util/page-name-sanity-lc (name prop-name))
@@ -112,7 +112,7 @@
   {:pre [(qualified-keyword? (:db/ident block))]}
   (block-with-timestamps
    (cond-> (merge block
-                  {:block/type (set (concat (:block/type block) ["class" "page"]))
+                  {:block/type "class"
                    :block/format :markdown})
      (not= (:db/ident block) :logseq.class/Root)
      (assoc :class/parent :logseq.class/Root))))
@@ -125,8 +125,9 @@
     :block/title page-name
     :block/uuid (d/squuid)
     :block/format :markdown
-    :block/type #{"page"}}))
+    :block/type "page"}))
 
 (defn page?
   [block]
-  (contains? (:block/type block) "page"))
+  (contains? #{"page" "journal" "whiteboard" "class" "property" "hidden"}
+             (:block/type block)))

+ 2 - 2
deps/db/test/logseq/db/sqlite/build_test.cljs

@@ -14,13 +14,13 @@
            [{:page {:block/title "page1"}
              :blocks [{:block/title "Jrue Holiday" :build/tags [:Person]}]}
             {:page {:block/title "Jayson Tatum" :build/tags [:Person]}}])]
-    (is (= {:block/tags [{:block/title "Person", :block/type ["class" "page"]}]}
+    (is (= {:block/tags [{:block/title "Person", :block/type "class"}]}
            (first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/type]}]) ...]
                          :where [?b :block/title "Jrue Holiday"]]
                        @conn)))
         "Person class is created and correctly associated to a block")
 
-    (is (= {:block/tags [{:block/title "Person", :block/type ["class" "page"]}]}
+    (is (= {:block/tags [{:block/title "Person", :block/type "class"}]}
            (first (d/q '[:find [(pull ?b [{:block/tags [:block/title :block/type]}]) ...]
                          :where [?b :block/title "Jayson Tatum"]]
                        @conn)))

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

@@ -37,7 +37,7 @@
                                            (map #(keyword (namespace %) (string/replace (name %) #".[^.]+$" "")))
                                            set)]
           (is (= []
-                 (remove #(= ["closed value"] (:block/type %)) closed-value-ents))
+                 (remove #(= "closed value" (:block/type %)) closed-value-ents))
               "All property names that contain a '.' are closed values")
           (is (= #{}
                  (set/difference closed-value-properties (set default-idents)))
@@ -62,11 +62,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 (contains? (:block/type task) "class")
+    (is (= (:block/type task) "class")
         "Task class has correct type")
     (is (= 3 (count (:class/schema.properties task)))
         "Has correct number of task properties")
-    (is (every? #(contains? (:block/type %) "property")
+    (is (every? #(= (:block/type %) "property")
                 (:class/schema.properties task))
         "Each task property has correct type")))
 

+ 3 - 7
deps/graph-parser/src/logseq/graph_parser/block.cljs

@@ -345,7 +345,7 @@
                         {:block/created-at current-ms
                          :block/updated-at current-ms}))
                     (if journal-day
-                      {:block/type #{"journal"}
+                      {:block/type "journal"
                        :block/journal-day journal-day}
                       {})))
 
@@ -358,12 +358,8 @@
                  :else
                  nil)]
       (when page
-        (let [type (:block/type page)
-              type' (if (string? type) [type] type)
-              type' (cons "page" type')
-              type' (if class? (cons "class" type') type')
-              types (set type')]
-          (assoc page :block/type types))))))
+        (let [type (if class? "class" (or (:block/type page) "page"))]
+          (assoc page :block/type type))))))
 
 (defn- with-page-refs-and-tags
   [{:keys [title body tags refs marker priority] :as block} db date-formatter]

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

@@ -202,7 +202,7 @@
                                           (date-time-util/int->journal-title date-int (common-config/get-date-formatter user-config)))]
                               (assoc page-m
                                      :block/uuid (common-uuid/gen-uuid :journal-page-uuid date-int)
-                                     :block/type (conj (:block/type page-m) "journal")
+                                     :block/type "journal"
                                      :block/journal-day date-int)))]
       {:block
        (-> block
@@ -263,7 +263,7 @@
   (let [prop-type (cond (and (coll? prop-val)
                              (seq prop-val)
                              (set/subset? prop-val
-                                          (set (keep #(when (contains? (:block/type %) "journal")
+                                          (set (keep #(when (= (:block/type %) "journal")
                                                         (:block/title %)) refs))))
                         :date
                         (and (coll? prop-val) (seq prop-val) (text-with-refs? prop-val prop-val-text))
@@ -890,8 +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 #(or (contains? (set (:block/type %)) "whiteboard")
-                                           (= "whiteboard" (:block/type %))))
+                              (filter #(= (:block/type %) "whiteboard"))
                               (map (fn [page-block]
                                      (-> page-block
                                          (assoc :block/format :markdown

+ 3 - 3
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -220,7 +220,7 @@
                       (vec))
           ref-pages (atom #{})
           blocks (map (fn [block]
-                        (if (contains? (:block/type block) "macro")
+                        (if (= (:block/type block) "macro")
                           block
                           (let [block-ref-pages (seq (:block/refs block))]
                             (when block-ref-pages
@@ -320,13 +320,13 @@
                           (filepath->page-name file))
                       (common-util/page-name-sanity-lc))
         title (or (:block/title serialized-page)
-                          page-name)
+                  page-name)
         page-block (merge {:block/name page-name
                            :block/title title
                            :block/file {:file/path (common-util/path-normalize file)}}
                           serialized-page
                           ;; Ensure old whiteboards have correct type
-                          {:block/type #{"whiteboard" "page"}})
+                          {:block/type "whiteboard"})
         page-block (gp-whiteboard/migrate-page-block page-block)
         blocks (->> blocks
                     (map gp-whiteboard/migrate-shape-block)

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

@@ -171,7 +171,7 @@
       (is (= 6
              (count (->> (d/q '[:find [(pull ?b [:block/title :block/type]) ...]
                                 :where [?b :block/title] [_ :block/page ?b]] @conn)
-                         (filter #(= ["page"] (:block/type %))))))
+                         (filter #(= "page" (:block/type %))))))
           "Correct number of pages with block content")
       (is (= 4 (count (d/datoms @conn :avet :block/type "whiteboard"))))
       (is (= 1 (count @(:ignored-properties import-state))) ":filters should be the only ignored property")
@@ -375,7 +375,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 (contains? (set (:block/type tag-page)) "class")))
+        (is (and tag-page (not (= (:block/type tag-page) "class")))
             "tag page is not a class")
 
         (is (= {:logseq.property/page-tags #{"Movie"}}
@@ -404,9 +404,9 @@
              (:block/tags (readable-properties @conn block)))
           "tagged block has configured tag imported as a class")
 
-      (is (= ["class" "page"] (:block/type tag-page))
+      (is (= "class" (:block/type tag-page))
           "configured tag page in :tag-classes is a class")
-      (is (and another-tag-page (not (contains? (set (:block/type another-tag-page)) "class")))
+      (is (and another-tag-page (not= (:block/type another-tag-page) "class"))
           "unconfigured tag page is not a class")
 
       (is (= {:block/tags [:user.class/Movie]}
@@ -465,7 +465,7 @@
           "tagged block can have another property that references the same class it is tagged with,
            without creating a duplicate class")
 
-      (is (= ["class" "page"] (:block/type tag-page))
+      (is (= "class" (:block/type tag-page))
           "configured tag page derived from :property-classes is a class")
       (is (nil? (find-page-by-name @conn "type"))
           "No page exists for configured property")

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

@@ -144,6 +144,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" "page"}))
+    (is (= (:block/type page) "whiteboard"))
     (is (= (:block/title page) "Foo"))
     (is (every? #(= (:block/parent %) [:block/uuid #uuid "a846e3b4-c41d-4251-80e1-be6978c36d8c"]) blocks))))

+ 1 - 1
deps/graph-parser/test/logseq/graph_parser_test.cljs

@@ -99,7 +99,7 @@
             parent (:block/page (ffirst blocks))]
         (is (= {:block/name "foo"
                 :block/title "Foo"
-                :block/type ["page" "whiteboard"]
+                :block/type "whiteboard"
                 :block/file {:file/path "/whiteboards/foo.edn"}}
                parent)
             "parsed block in the whiteboard page has correct parent page"))))

File diff suppressed because it is too large
+ 0 - 0
deps/graph-parser/test/resources/exporter-test-graph/whiteboards/Test Whiteboard.edn


+ 125 - 127
deps/graph-parser/test/resources/exporter-test-graph/whiteboards/block tests.edn

@@ -1,127 +1,125 @@
-{:blocks (
-{:block/title "block with page ref [[some page]]"
-:block/created-at 1720805247589
-:block/format :markdown
-:block/parent
-{:block/uuid #uuid "6691676f-2eed-4619-b56a-69fd7d572c59"}
-:block/properties
-{}
-:block/updated-at 1720809014394
-:block/uuid #uuid "6691677f-c208-4c83-aa40-6efc4286100c"} 
-{:block/created-at 1721935480784
-:block/properties 
-{:ls-type :whiteboard-shape
-:logseq.tldraw.shape
-{:blockType "B"
-:stroke ""
-:collapsed false
-:borderRadius 8
-:scale [1 1]
-:pageId "6691677f-c208-4c83-aa40-6efc4286100c"
-:scaleLevel "md"
-:fill ""
-:compact true
-:isAutoResizing true
-:type "logseq-portal"
-:size [400 124.9781494140625]
-:strokeType "line"
-:strokeWidth 2
-:opacity 1
-:id "01b33340-4074-11ef-956e-7d9aebf284ae"
-:noFill false
-:point [430.41563108563423 233.00156784057617]
-:parentId "6691676f-2eed-4619-b56a-69fd7d572c59"
-:collapsedHeight 0
-:nonce 1720805246071
-:pageName nil}}
-:block/updated-at 1721935480784} 
-{:block/title "block with block ref ((669168ed-8734-4943-8a86-5e3a553a526d))"
-:block/created-at 1720808993012
-:block/format :markdown
-:block/parent
-{:block/uuid #uuid "6691676f-2eed-4619-b56a-69fd7d572c59"}
-:block/properties
-{}
-:block/updated-at 1720809157098
-:block/uuid #uuid "66917621-93ae-475b-aa4c-6ae9e797cf68"}
-{:block/properties
-{:ls-type :whiteboard-shape
-:logseq.tldraw.shape
-{:blockType "B"
-:stroke ""
-:collapsed false
-:borderRadius 8
-:scale [1 1]
-:pageId "66917621-93ae-475b-aa4c-6ae9e797cf68"
-:scaleLevel "md"
-:fill ""
-:compact true
-:isAutoResizing true
-:type "logseq-portal"
-:size [400 79.9781265258789]
-:strokeType "line"
-:strokeWidth 2
-:opacity 1
-:id "b999ee10-407c-11ef-956e-7d9aebf284ae"
-:noFill false
-:point [478.6382088826831 337.7821947259741]
-:parentId "6691676f-2eed-4619-b56a-69fd7d572c59"
-:collapsedHeight 0
-:nonce 1720808990579
-:pageName nil}}
-:block/updated-at 1720809157310
-:block/created-at 1720809157310} 
-{:block/title "block with props\nprop-num:: 10"
-:block/created-at 1721935480737
-:block/format :markdown
-:block/parent 
-{:block/uuid #uuid "6691676f-2eed-4619-b56a-69fd7d572c59"}
-:block/properties 
-{:prop-num 10}
-:block/updated-at 1721935504617
-:block/uuid #uuid "66a2a678-1cea-44b6-a458-4b8c15e18a8d"} 
-{:block/properties 
-{:ls-type :whiteboard-shape
-:logseq.tldraw.shape 
-{:blockType "B"
-:stroke ""
-:collapsed false
-:borderRadius 8
-:scale [1 1]
-:pageId "66a2a678-1cea-44b6-a458-4b8c15e18a8d"
-:scaleLevel "md"
-:fill ""
-:compact true
-:isAutoResizing true
-:type "logseq-portal"
-:size [400 320]
-:strokeType "line"
-:strokeWidth 2
-:opacity 1
-:id "86f86420-4abb-11ef-9161-b98dd17dbef1"
-:noFill false
-:point [648.5671437694965 179.003191006195]
-:parentId "6691676f-2eed-4619-b56a-69fd7d572c59"
-:collapsedHeight 0
-:nonce 1721935475555
-:pageName nil}}
-:block/updated-at 1721935504609
-:block/created-at 1721935504609})
-:pages (
-{:block/tx-id 536871657
-:block/uuid #uuid "6691676f-2eed-4619-b56a-69fd7d572c59"
-:block/properties
-{:ls-type :whiteboard-page
-:logseq.tldraw.page
-{:id "6691676f-2eed-4619-b56a-69fd7d572c59"
-:name "ref page"
-:bindings
-{}
-:nonce 1
-:assets []}}
-:block/updated-at 1721935504609
-:block/created-at 1720805231835
-:block/format :markdown
-:block/type ["page" "whiteboard"]
-:block/name "ref page"
-:block/title "ref page"})}
+{:blocks ({:block/title "block with page ref [[some page]]"
+           :block/created-at 1720805247589
+           :block/format :markdown
+           :block/parent
+           {:block/uuid #uuid "6691676f-2eed-4619-b56a-69fd7d572c59"}
+           :block/properties
+           {}
+           :block/updated-at 1720809014394
+           :block/uuid #uuid "6691677f-c208-4c83-aa40-6efc4286100c"}
+          {:block/created-at 1721935480784
+           :block/properties
+           {:ls-type :whiteboard-shape
+            :logseq.tldraw.shape
+            {:blockType "B"
+             :stroke ""
+             :collapsed false
+             :borderRadius 8
+             :scale [1 1]
+             :pageId "6691677f-c208-4c83-aa40-6efc4286100c"
+             :scaleLevel "md"
+             :fill ""
+             :compact true
+             :isAutoResizing true
+             :type "logseq-portal"
+             :size [400 124.9781494140625]
+             :strokeType "line"
+             :strokeWidth 2
+             :opacity 1
+             :id "01b33340-4074-11ef-956e-7d9aebf284ae"
+             :noFill false
+             :point [430.41563108563423 233.00156784057617]
+             :parentId "6691676f-2eed-4619-b56a-69fd7d572c59"
+             :collapsedHeight 0
+             :nonce 1720805246071
+             :pageName nil}}
+           :block/updated-at 1721935480784}
+          {:block/title "block with block ref ((669168ed-8734-4943-8a86-5e3a553a526d))"
+           :block/created-at 1720808993012
+           :block/format :markdown
+           :block/parent
+           {:block/uuid #uuid "6691676f-2eed-4619-b56a-69fd7d572c59"}
+           :block/properties
+           {}
+           :block/updated-at 1720809157098
+           :block/uuid #uuid "66917621-93ae-475b-aa4c-6ae9e797cf68"}
+          {:block/properties
+           {:ls-type :whiteboard-shape
+            :logseq.tldraw.shape
+            {:blockType "B"
+             :stroke ""
+             :collapsed false
+             :borderRadius 8
+             :scale [1 1]
+             :pageId "66917621-93ae-475b-aa4c-6ae9e797cf68"
+             :scaleLevel "md"
+             :fill ""
+             :compact true
+             :isAutoResizing true
+             :type "logseq-portal"
+             :size [400 79.9781265258789]
+             :strokeType "line"
+             :strokeWidth 2
+             :opacity 1
+             :id "b999ee10-407c-11ef-956e-7d9aebf284ae"
+             :noFill false
+             :point [478.6382088826831 337.7821947259741]
+             :parentId "6691676f-2eed-4619-b56a-69fd7d572c59"
+             :collapsedHeight 0
+             :nonce 1720808990579
+             :pageName nil}}
+           :block/updated-at 1720809157310
+           :block/created-at 1720809157310}
+          {:block/title "block with props\nprop-num:: 10"
+           :block/created-at 1721935480737
+           :block/format :markdown
+           :block/parent
+           {:block/uuid #uuid "6691676f-2eed-4619-b56a-69fd7d572c59"}
+           :block/properties
+           {:prop-num 10}
+           :block/updated-at 1721935504617
+           :block/uuid #uuid "66a2a678-1cea-44b6-a458-4b8c15e18a8d"}
+          {:block/properties
+           {:ls-type :whiteboard-shape
+            :logseq.tldraw.shape
+            {:blockType "B"
+             :stroke ""
+             :collapsed false
+             :borderRadius 8
+             :scale [1 1]
+             :pageId "66a2a678-1cea-44b6-a458-4b8c15e18a8d"
+             :scaleLevel "md"
+             :fill ""
+             :compact true
+             :isAutoResizing true
+             :type "logseq-portal"
+             :size [400 320]
+             :strokeType "line"
+             :strokeWidth 2
+             :opacity 1
+             :id "86f86420-4abb-11ef-9161-b98dd17dbef1"
+             :noFill false
+             :point [648.5671437694965 179.003191006195]
+             :parentId "6691676f-2eed-4619-b56a-69fd7d572c59"
+             :collapsedHeight 0
+             :nonce 1721935475555
+             :pageName nil}}
+           :block/updated-at 1721935504609
+           :block/created-at 1721935504609})
+ :pages ({:block/tx-id 536871657
+          :block/uuid #uuid "6691676f-2eed-4619-b56a-69fd7d572c59"
+          :block/properties
+          {:ls-type :whiteboard-page
+           :logseq.tldraw.page
+           {:id "6691676f-2eed-4619-b56a-69fd7d572c59"
+            :name "ref page"
+            :bindings
+            {}
+            :nonce 1
+            :assets []}}
+          :block/updated-at 1721935504609
+          :block/created-at 1720805231835
+          :block/format :markdown
+          :block/type "whiteboard"
+          :block/name "ref page"
+          :block/title "ref page"})}

+ 1 - 1
deps/graph-parser/test/resources/exporter-test-graph/whiteboards/publishing test.edn

@@ -438,6 +438,6 @@
             :shapes-index ("665eeab0-ccca-11ed-8c36-cd64b4f8676b" "689db722-ccca-11ed-8c36-cd64b4f8676b" "08b11d80-cda0-11ed-8356-d36ee09ec21e" "a5ced1d0-d3cb-11ed-84d2-d9f3e7dd8e6d" "c80e4880-dad2-11ed-b0d8-ef9040ba205f" "cae02d30-dad2-11ed-b0d8-ef9040ba205f" "ce9d5c40-dad2-11ed-b0d8-ef9040ba205f" "d0eb6af0-dad2-11ed-b0d8-ef9040ba205f" "d51c4360-dad2-11ed-b0d8-ef9040ba205f" "17a61b70-dad3-11ed-b0d8-ef9040ba205f" "1ee6f300-dad3-11ed-b0d8-ef9040ba205f" "46999ba0-dad3-11ed-b0d8-ef9040ba205f" "4ac3e461-dad3-11ed-b0d8-ef9040ba205f" "3f1d1b80-cdaa-11ed-8356-d36ee09ec21e" "eb97f800-dfa0-11ed-8d23-dd2d2525f6dc")}}
           :block/updated-at 1707842737378
           :block/created-at 1679940473374
-          :block/type ["whiteboard"]
+          :block/type "whiteboard"
           :block/name "publishing test"
           :block/title "publishing test"})}

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

@@ -333,7 +333,7 @@
 
 (defn ^:api get-class-parents
   [tags]
-  (let [tags' (filter (fn [tag] (contains? (:block/type tag) "class")) tags)]
+  (let [tags' (filter (fn [tag] (= (:block/type tag) "class")) tags)]
     (set (mapcat ldb/get-class-parents tags'))))
 
 (defn ^:api get-class-properties
@@ -349,7 +349,7 @@
   (let [block (d/entity db eid)
         classes (->> (:block/tags block)
                      (sort-by :block/name)
-                     (filter (fn [tag] (contains? (:block/type tag) "class"))))
+                     (filter (fn [tag] (= (:block/type tag) "class"))))
         class-parents (get-class-parents classes)
         all-classes (->> (concat classes class-parents)
                          (filter (fn [class]
@@ -517,7 +517,7 @@
 (defn class-add-property!
   [conn class-id property-id]
   (when-let [class (d/entity @conn class-id)]
-    (if (contains? (:block/type class) "class")
+    (if (= (:block/type class) "class")
       (ldb/transact! conn
                      [[:db/add (:db/id class) :class/schema.properties property-id]]
                      {:outliner-op :save-block})
@@ -527,7 +527,7 @@
 (defn class-remove-property!
   [conn class-id property-id]
   (when-let [class (d/entity @conn class-id)]
-    (when (contains? (:block/type class) "class")
+    (when (= (:block/type class) "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]]

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

@@ -13,7 +13,7 @@
 
 (sr/defkeyword :block/type
   "block type"
-  [:set [:enum "page" "property" "class" "whiteboard" "hidden"]])
+  [:enum "page" "property" "class" "whiteboard" "hidden"])
 
 (sr/defkeyword :block/parent
   "page blocks don't have this attr")

+ 2 - 2
src/main/frontend/components/all_pages.cljs

@@ -23,8 +23,8 @@
            :type :string}
           {:id :block/type
            :name "Type"
-           :cell (fn [_table row _column] [:div.capitalize (string/join ", " (get row :block/type))])
-           :get-value (fn [row] (string/join ", " (get row :block/type)))
+           :cell (fn [_table row _column] [:div.capitalize (get row :block/type)])
+           :get-value (fn [row] (get row :block/type))
            :type :string}
           (when db-based?
             {:id :block/tags

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

@@ -52,9 +52,9 @@
   [state page *mode]
   (let [*mode *mode
         mode (rum/react *mode)
-        types (:block/type page)
-        class? (contains? types "class")
-        property? (contains? types "property")
+        type (:block/type page)
+        class? (= type "class")
+        property? (= type "property")
         page-opts {:configure? true}]
     (when (nil? mode)
       (reset! *mode (cond
@@ -74,10 +74,10 @@
        (page-properties page (assoc page-opts :mode mode)))]))
 
 (rum/defc mode-switch < rum/reactive
-  [types *mode]
+  [type *mode]
   (let [current-mode (rum/react *mode)
-        class? (contains? types "class")
-        property? (contains? types "property")
+        class? (= type "class")
+        property? (= type "property")
         modes (->
                (cond
                  property?
@@ -106,8 +106,8 @@
   (let [page (db/sub-block (:db/id page))
         *hover? (::hover? state)
         *mode (::mode state)
-        types (:block/type page)
-        class? (contains? types "class")
+        type (:block/type page)
+        class? (= type "class")
         collapsed? (not @*show-info?)
         has-properties? (or
                          (seq (:block/tags page))
@@ -118,7 +118,7 @@
     (when (if config/publishing?
             ;; Since publishing is read-only, hide this component if it has no info to show
             ;; as it creates a fair amount of empty vertical space
-            (some? types)
+            (some? type)
             show-info?)
       [:div.page-info
        {:class (util/classnames [{:is-collapsed collapsed?}])}
@@ -132,14 +132,14 @@
                                (reset! *hover? false))
             :on-click (if config/publishing?
                         (fn [_]
-                          (when (seq (set/intersection #{"class" "property"} types))
+                          (when (contains? #{"class" "property"} type)
                             (swap! *show-info? not)))
                         #(do
                            (swap! *show-info? not)
                            (swap! *hover? not)))}
            [:<>
             [:div.flex.flex-row.items-center.gap-1
-             (mode-switch types *mode)]
+             (mode-switch type *mode)]
             [:div.absolute.right-1.top-1
              (shui/button
               {:variant :ghost :size :sm

+ 2 - 2
src/main/frontend/components/imports.cljs

@@ -238,9 +238,9 @@
   {:entities (count entities)
    :pages (count (filter :block/name entities))
    :blocks (count (filter :block/title entities))
-   :classes (count (filter #(contains? (:block/type %) "class") entities))
+   :classes (count (filter #(= (:block/type %) "class") entities))
    :objects (count (filter #(seq (:block/tags %)) entities))
-   :properties (count (filter #(contains? (:block/type %) "property") entities))
+   :properties (count (filter #(= (:block/type %) "property") entities))
    :property-values (count (mapcat :block/properties entities))})
 
 (defn- validate-imported-data

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

@@ -586,7 +586,7 @@
             (when (and (not block?) (not db-based?))
               (tagged-pages repo page page-title))
 
-            (when (contains? (:block/type page) "class")
+            (when (= (:block/type page) "class")
               (class-component/class-children page))
 
             ;; referenced blocks

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

@@ -50,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? (contains? (set (:block/type page)) "whiteboard")
+          whiteboard? (= (:block/type page) "whiteboard")
           block? (and page (util/uuid-string? page-name) (not whiteboard?))
           contents? (= page-name "contents")
           public? (pu/get-block-property-value page :logseq.property/public)

+ 4 - 4
src/main/frontend/components/property.cljs

@@ -112,7 +112,7 @@
 
 (defn- handle-delete-property!
   [block property & {:keys [class? class-schema?]}]
-  (let [class? (or class? (some-> block :block/type (contains? "class")))
+  (let [class? (or class? (= (:block/type block) "class"))
         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 +130,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 (contains? (:block/type entity) "class") page-configure? class-schema?)
+          add-class-property? (and (= (:block/type entity) "class") 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 +192,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 (contains? (:block/type block) "class") page-configure? class-schema?)]
+                      add-class-property? (and (= (:block/type block) "class") page-configure? class-schema?)]
                 (when *property (reset! *property property))
                 (p/do!
                  (when *show-new-property-config? (reset! *show-new-property-config? false))
@@ -459,7 +459,7 @@
         (reset! *show-new-property-config? true))
       (reset! *property property)
       (when property
-        (let [add-class-property? (and (contains? (:block/type block) "class") class-schema?)
+        (let [add-class-property? (and (= (:block/type block) "class") class-schema?)
               type (get-in property [:block/schema :type])]
           (cond
             add-class-property?

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

@@ -99,7 +99,7 @@
   ([block property-id property-value' {:keys [exit-edit? class-schema?]
                                        :or {exit-edit? true}}]
    (let [repo (state/get-current-repo)
-         class? (contains? (:block/type block) "class")
+         class? (= (:block/type block) "class")
          property (db/entity property-id)
          many? (db-property/many? property)
          checkbox? (= :checkbox (get-in property [:block/schema :type]))]
@@ -563,7 +563,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? (contains? (:block/type v-block) "class")
+        (let [class? (= (:block/type v-block) "class")
               invalid-warning [:div.warning.text-sm
                                "Invalid block value, please delete the current property."]]
           (when v-block

+ 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 (contains? (:block/type page) "whiteboard") "whiteboard" "page") {:class "text-md mr-2"}))
+            (ui/icon (if (= (:block/type page) "whiteboard") "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)))

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

@@ -1311,7 +1311,7 @@
   [block value opts]
   (let [entity (db/entity [:block/uuid (:block/uuid block)])]
     (when (and (:db/id entity)
-               (not (contains? (:block/type entity) "property")))
+               (not (= (:block/type entity) "property")))
       (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?

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

@@ -247,16 +247,16 @@
   (let [graph-specific-hidden?
         (if (config/db-based-graph? repo)
           (fn [p]
-            (and (contains? (set (:block/type p)) "property") (ldb/built-in? p)))
+            (and (= (:block/type p) "property") (ldb/built-in? p)))
           (fn [p]
             (gp-db/built-in-pages-names (string/upper-case (:block/name p)))))]
     (->> (db/get-all-pages repo)
-        (remove (fn [p]
-                  (let [name (:block/name p)]
-                    (or (util/uuid-string? name)
-                        (common-config/draw? name)
-                        (graph-specific-hidden? p)))))
-        (common-handler/fix-pages-timestamps))))
+         (remove (fn [p]
+                   (let [name (:block/name p)]
+                     (or (util/uuid-string? name)
+                         (common-config/draw? name)
+                         (graph-specific-hidden? p)))))
+         (common-handler/fix-pages-timestamps))))
 
 (defn get-filters
   [page]

+ 3 - 3
src/main/frontend/handler/whiteboard.cljs

@@ -69,7 +69,7 @@
     {:db/id (:db/id page-entity)
      :block/title page-name
      :block/name (util/page-name-sanity-lc page-name)
-     :block/type #{"page" "whiteboard"}
+     :block/type "whiteboard"
      :block/format :markdown
      :logseq.property/ls-type :whiteboard-page
      :logseq.property.tldraw/page tldraw-page
@@ -82,7 +82,7 @@
   (let [get-k #(gobj/get tldraw-page %)]
     {:block/title page-name
      :block/name (util/page-name-sanity-lc page-name)
-     :block/type #{"page" "whiteboard"}
+     :block/type "whiteboard"
      :block/properties {(pu/get-pid :logseq.property/ls-type)
                         :whiteboard-page
 
@@ -253,7 +253,7 @@
         m #:block{:uuid id
                   :name (util/page-name-sanity-lc page-name),
                   :title page-name
-                  :type #{"whiteboard" "page"},
+                  :type "whiteboard",
                   :format :markdown
                   :updated-at (util/time-ms),
                   :created-at (util/time-ms)}

+ 5 - 3
src/main/frontend/worker/db/migrate.cljs

@@ -49,9 +49,11 @@
        :classes    []}]
    [4 {:fix (fn [conn _search-db]
               (let [pages (d/datoms @conn :avet :block/name)
-                    tx-data (map (fn [d]
-                                   {:db/id (:e d)
-                                    :block/type "page"}) pages)]
+                    tx-data (keep (fn [d]
+                                    (let [entity (d/entity @conn (:e d))]
+                                      (when-not (:block/type entity)
+                                        {:db/id (:e d)
+                                         :block/type "page"}))) pages)]
                 tx-data))}]
    [5 {:properties [:logseq.property/view-for]
        :classes    []}]

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

@@ -39,7 +39,7 @@
               [?b :block/name]] db)
 
        (map (fn [[page]]
-              (let [whiteboard? (contains? (set (:block/type page)) "whiteboard")
+              (let [whiteboard? (= (:block/type page) "whiteboard")
                     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? (contains? (set (:block/type page-block)) "whiteboard")
+        whiteboard? (= (:block/type page-block) "whiteboard")
         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))]

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

@@ -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 (contains? (set (:block/type page-block)) "whiteboard")
+                 (let [new-content (if (= (:block/type page-block) "whiteboard")
                                      (->
                                       (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) (contains? (:block/type page) "hidden"))
+        (if (or (ldb/built-in? page) (= (:block/type page) "hidden"))
           (do
             (error-handler {:msg "Built-in page cannot be deleted"})
             false)

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

@@ -15,8 +15,7 @@
 
 (defn- build-page-tx [conn properties page {:keys [whiteboard? class? tags]}]
   (when (:block/uuid page)
-    (let [page (update page :block/type
-                       (fn [types] (if whiteboard? (conj types "whiteboard") types)))
+    (let [page (assoc page :block/type (cond class? "class" whiteboard? "whiteboard" :else "page"))
           page' (merge page
                        (when tags {:block/tags (mapv #(hash-map :db/id
                                                                 (:db/id (d/entity @conn [:block/uuid %])))

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

@@ -31,7 +31,7 @@
   (when (:block/uuid page)
     (let [page-entity   [:block/uuid (:block/uuid page)]
           page'          (merge page
-                                (when whiteboard? {:block/type #{"page" "whiteboard"}})
+                                (when whiteboard? {:block/type "whiteboard"})
                                 (when tags {:block/tags (mapv #(hash-map :db/id
                                                                          (:db/id (d/entity @conn [:block/uuid %])))
                                                               tags)}))

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

@@ -319,8 +319,8 @@
       :invalid-empty-name
 
       (and page-e new-page-e
-           (or (contains? (:block/type page-e) "whiteboard")
-               (contains? (:block/type new-page-e) "whiteboard")))
+           (or (= (:block/type page-e) "whiteboard")
+               (= (:block/type new-page-e) "whiteboard")))
       :merge-whiteboard-pages
 
       (and old-name new-name name-changed?)

+ 1 - 1
src/main/frontend/worker/rtc/asset_db_listener.cljs

@@ -12,7 +12,7 @@
     (let [ent (d/entity db-after e)
           block-uuid (:block/uuid ent)
           block-type (:block/type ent)]
-      (when (and block-uuid (contains? (set block-type) "asset"))
+      (when (and block-uuid (= block-type "asset"))
         (when-let [action (r.asset/asset-block->upload+download-action ent)]
           [action block-uuid])))))
 

+ 3 - 4
src/main/frontend/worker/rtc/db_listener.cljs

@@ -76,8 +76,8 @@
 (defn- entity-datoms=>ops
   [db-before db-after e->a->add?->v->t entity-datoms]
   (let [e                        (ffirst entity-datoms)
-        {block-uuid :block/uuid
-         block-type :block/type} (d/entity db-after e)
+        entity                   (d/entity db-after e)
+        {block-uuid :block/uuid} entity
         a->add?->v->t            (e->a->add?->v->t e)
         {add?->block-name->t   :block/name
          add?->block-title->t  :block/title
@@ -107,8 +107,7 @@
                   (conj [:move (or t4 t5) {:block-uuid block-uuid}])
 
                   (or add-block-name
-                      (and (contains? block-type "page")
-                           add-block-title))
+                      (and (ldb/page? entity) add-block-title))
                   (conj [:update-page (or t2 t3) {:block-uuid block-uuid}]))
             update-op (when-let [av-coll (not-empty (update-op-av-coll db-before db-after a->add?->v->t*))]
                         (let [t (max-t a->add?->v->t*)]

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

@@ -129,17 +129,13 @@
   (ldb/transact! conn blocks {:persist-op? false
                               :gen-undo-ops? false}))
 
-(defn- whiteboard-page-block?
-  [block]
-  (contains? (set (:block/type block)) "whiteboard"))
-
 (defn- group-remote-remove-ops-by-whiteboard-block
   "return {true [<whiteboard-block-ops>], false [<other-ops>]}"
   [db remote-remove-ops]
   (group-by (fn [{:keys [block-uuid]}]
               (boolean
                (when-let [block (d/entity db [:block/uuid block-uuid])]
-                 (whiteboard-page-block? (:block/parent block)))))
+                 (ldb/whiteboard-page? (:block/parent block)))))
             remote-remove-ops))
 
 (defn- apply-remote-remove-ops-helper
@@ -186,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? (whiteboard-page-block? local-parent)
+          whiteboard-page-block? (ldb/whiteboard-page? local-parent)
           b (d/entity @conn [:block/uuid block-uuid])]
       (case [whiteboard-page-block? (some? local-parent) (some? remote-block-order)]
         [false true true]
@@ -459,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? (whiteboard-page-block? local-parent)]
+            whiteboard-page-block? (ldb/whiteboard-page? 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)]

+ 2 - 2
src/main/frontend/worker/search.cljs

@@ -180,7 +180,7 @@ DROP TRIGGER IF EXISTS blocks_au;
   (when page
     (if (string? page)
       (string/starts-with? page "$$$")
-      (contains? (set (:block/type page)) "hidden"))))
+      (= (:block/type page) "hidden"))))
 
 (defn- page-or-object?
   [entity]
@@ -318,7 +318,7 @@ DROP TRIGGER IF EXISTS blocks_au;
   (defn- property-value-when-closed
     "Returns property value if the given entity is type 'closed value' or nil"
     [ent]
-    (when (contains? (:block/type ent) "closed value")
+    (when (= (:block/type ent) "closed value")
       (:block/title ent))))
 
 (comment

+ 2 - 2
src/test/frontend/worker/rtc/client_test.cljs

@@ -16,7 +16,7 @@
                                    :block/created-at 1720017595872,
                                    :block/format :markdown,
                                    :db/ident :user.class/yyy,
-                                   :block/type ["class"],
+                                   :block/type "class",
                                    :block/name "yyy",
                                    :block/title "yyy"}])]
       (is (= {:update
@@ -50,7 +50,7 @@
                                    :block/format :markdown
                                    :db/cardinality :db.cardinality/one
                                    :db/ident :user.property/xxx,
-                                   :block/type #{"property"},
+                                   :block/type "property",
                                    :block/order block-order,
                                    :block/name "xxx",
                                    :block/title "xxx"}])]

Some files were not shown because too many files changed in this diff