diff --git a/deps/db/script/validate_client_db.cljs b/deps/db/script/validate_client_db.cljs index 50f7b8b378..d1f90f0b3a 100644 --- a/deps/db/script/validate_client_db.cljs +++ b/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))) diff --git a/deps/db/src/logseq/db.cljs b/deps/db/src/logseq/db.cljs index 78b47266df..cc79bdf4e2 100644 --- a/deps/db/src/logseq/db.cljs +++ b/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))))) diff --git a/deps/db/src/logseq/db/frontend/malli_schema.cljs b/deps/db/src/logseq/db/frontend/malli_schema.cljs index b1a2dabda5..91ec1f8669 100644 --- a/deps/db/src/logseq/db/frontend/malli_schema.cljs +++ b/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 diff --git a/deps/db/src/logseq/db/frontend/property/build.cljs b/deps/db/src/logseq/db/frontend/property/build.cljs index 7b8a4d2410..1db8b93d79 100644 --- a/deps/db/src/logseq/db/frontend/property/build.cljs +++ b/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 diff --git a/deps/db/src/logseq/db/frontend/property/type.cljs b/deps/db/src/logseq/db/frontend/property/type.cljs index 98cdb601a4..9c1af5c54c 100644 --- a/deps/db/src/logseq/db/frontend/property/type.cljs +++ b/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 diff --git a/deps/db/src/logseq/db/frontend/schema.cljs b/deps/db/src/logseq/db/frontend/schema.cljs index 8dd9502338..5cc18c29e5 100644 --- a/deps/db/src/logseq/db/frontend/schema.cljs +++ b/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 diff --git a/deps/db/src/logseq/db/sqlite/build.cljs b/deps/db/src/logseq/db/sqlite/build.cljs index 8858af2da3..9015cfbeba 100644 --- a/deps/db/src/logseq/db/sqlite/build.cljs +++ b/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 diff --git a/deps/db/src/logseq/db/sqlite/common_db.cljs b/deps/db/src/logseq/db/sqlite/common_db.cljs index dc37923993..a0e9f53c26 100644 --- a/deps/db/src/logseq/db/sqlite/common_db.cljs +++ b/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])) diff --git a/deps/db/src/logseq/db/sqlite/create_graph.cljs b/deps/db/src/logseq/db/sqlite/create_graph.cljs index 37cf9a48b4..d77d663bdd 100644 --- a/deps/db/src/logseq/db/sqlite/create_graph.cljs +++ b/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 diff --git a/deps/db/src/logseq/db/sqlite/util.cljs b/deps/db/src/logseq/db/sqlite/util.cljs index 879fffd514..ccbf9e0d6d 100644 --- a/deps/db/src/logseq/db/sqlite/util.cljs +++ b/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))) diff --git a/deps/db/test/logseq/db/sqlite/build_test.cljs b/deps/db/test/logseq/db/sqlite/build_test.cljs index b3b3652b9a..2004e34340 100644 --- a/deps/db/test/logseq/db/sqlite/build_test.cljs +++ b/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))) diff --git a/deps/db/test/logseq/db/sqlite/create_graph_test.cljs b/deps/db/test/logseq/db/sqlite/create_graph_test.cljs index f20112d474..c8a4a40623 100644 --- a/deps/db/test/logseq/db/sqlite/create_graph_test.cljs +++ b/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"))) diff --git a/deps/graph-parser/src/logseq/graph_parser/block.cljs b/deps/graph-parser/src/logseq/graph_parser/block.cljs index e674ac4c40..82e5c6260d 100644 --- a/deps/graph-parser/src/logseq/graph_parser/block.cljs +++ b/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] diff --git a/deps/graph-parser/src/logseq/graph_parser/exporter.cljs b/deps/graph-parser/src/logseq/graph_parser/exporter.cljs index e88fb20316..98806dd1a0 100644 --- a/deps/graph-parser/src/logseq/graph_parser/exporter.cljs +++ b/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 diff --git a/deps/graph-parser/src/logseq/graph_parser/extract.cljc b/deps/graph-parser/src/logseq/graph_parser/extract.cljc index 58306cef39..39714f9484 100644 --- a/deps/graph-parser/src/logseq/graph_parser/extract.cljc +++ b/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) diff --git a/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs b/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs index 0e09b6182e..edc50774df 100644 --- a/deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs +++ b/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") diff --git a/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs b/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs index fbf1e4410c..0eb2f2e3a9 100644 --- a/deps/graph-parser/test/logseq/graph_parser/extract_test.cljs +++ b/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)))) diff --git a/deps/graph-parser/test/logseq/graph_parser_test.cljs b/deps/graph-parser/test/logseq/graph_parser_test.cljs index 56056faeea..c7b8d98a7a 100644 --- a/deps/graph-parser/test/logseq/graph_parser_test.cljs +++ b/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")))) diff --git a/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/Test Whiteboard.edn b/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/Test Whiteboard.edn index b6d30dc30e..7ef5f959c3 100644 --- a/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/Test Whiteboard.edn +++ b/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/Test Whiteboard.edn @@ -2418,6 +2418,6 @@ :shapes-index ("07b85b29-ca6a-11ed-8caa-efa6679223ca" "07b7bef3-ca6a-11ed-8caa-efa6679223ca" "07b7beed-ca6a-11ed-8caa-efa6679223ca" "07b7beea-ca6a-11ed-8caa-efa6679223ca" "07b7bf01-ca6a-11ed-8caa-efa6679223ca" "07b7bef1-ca6a-11ed-8caa-efa6679223ca" "07b85b22-ca6a-11ed-8caa-efa6679223ca" "07b7bef6-ca6a-11ed-8caa-efa6679223ca" "07b7bf06-ca6a-11ed-8caa-efa6679223ca" "07b7bf00-ca6a-11ed-8caa-efa6679223ca" "07b85b38-ca6a-11ed-8caa-efa6679223ca" "07b7bf10-ca6a-11ed-8caa-efa6679223ca" "07b7befd-ca6a-11ed-8caa-efa6679223ca" "07b85b32-ca6a-11ed-8caa-efa6679223ca" "07b7bef5-ca6a-11ed-8caa-efa6679223ca" "07b7bee9-ca6a-11ed-8caa-efa6679223ca" "07b85b21-ca6a-11ed-8caa-efa6679223ca" "07b7beeb-ca6a-11ed-8caa-efa6679223ca" "07b7bef9-ca6a-11ed-8caa-efa6679223ca" "07b7bf0d-ca6a-11ed-8caa-efa6679223ca" "07b7bf07-ca6a-11ed-8caa-efa6679223ca" "07b7bf0c-ca6a-11ed-8caa-efa6679223ca" "07b7befc-ca6a-11ed-8caa-efa6679223ca" "07b85b23-ca6a-11ed-8caa-efa6679223ca" "07b7bee0-ca6a-11ed-8caa-efa6679223ca" "07b85b26-ca6a-11ed-8caa-efa6679223ca" "07b85b35-ca6a-11ed-8caa-efa6679223ca" "07b7bee5-ca6a-11ed-8caa-efa6679223ca" "07b85b2b-ca6a-11ed-8caa-efa6679223ca" "07b7bf03-ca6a-11ed-8caa-efa6679223ca" "07b85b20-ca6a-11ed-8caa-efa6679223ca" "07b7bf0b-ca6a-11ed-8caa-efa6679223ca" "07b7beef-ca6a-11ed-8caa-efa6679223ca" "07b85b2d-ca6a-11ed-8caa-efa6679223ca" "07b7bf0e-ca6a-11ed-8caa-efa6679223ca" "07b7bef4-ca6a-11ed-8caa-efa6679223ca" "07b7bf13-ca6a-11ed-8caa-efa6679223ca" "07b7bee3-ca6a-11ed-8caa-efa6679223ca" "07b85b27-ca6a-11ed-8caa-efa6679223ca" "07b7bef8-ca6a-11ed-8caa-efa6679223ca" "07b7bee2-ca6a-11ed-8caa-efa6679223ca" "07b85b33-ca6a-11ed-8caa-efa6679223ca" "07b7bf12-ca6a-11ed-8caa-efa6679223ca" "07b7bee6-ca6a-11ed-8caa-efa6679223ca" "07b85b39-ca6a-11ed-8caa-efa6679223ca" "07b7bee1-ca6a-11ed-8caa-efa6679223ca" "07b85b2e-ca6a-11ed-8caa-efa6679223ca" "07b7beec-ca6a-11ed-8caa-efa6679223ca" "07b7bf02-ca6a-11ed-8caa-efa6679223ca" "07b7bf09-ca6a-11ed-8caa-efa6679223ca" "07b7befe-ca6a-11ed-8caa-efa6679223ca" "07b7beff-ca6a-11ed-8caa-efa6679223ca" "07b85b24-ca6a-11ed-8caa-efa6679223ca" "07b85b2c-ca6a-11ed-8caa-efa6679223ca" "07b85b2f-ca6a-11ed-8caa-efa6679223ca" "07b85b2a-ca6a-11ed-8caa-efa6679223ca" "07b7befb-ca6a-11ed-8caa-efa6679223ca" "07b85b28-ca6a-11ed-8caa-efa6679223ca" "07b7befa-ca6a-11ed-8caa-efa6679223ca" "07b85b36-ca6a-11ed-8caa-efa6679223ca" "07b85b25-ca6a-11ed-8caa-efa6679223ca" "07b85b37-ca6a-11ed-8caa-efa6679223ca" "07b7bf04-ca6a-11ed-8caa-efa6679223ca" "07b7bef2-ca6a-11ed-8caa-efa6679223ca" "07b7bee8-ca6a-11ed-8caa-efa6679223ca" "07b7bf08-ca6a-11ed-8caa-efa6679223ca" "07b7bee7-ca6a-11ed-8caa-efa6679223ca" "07b7bef7-ca6a-11ed-8caa-efa6679223ca" "07b7bf0f-ca6a-11ed-8caa-efa6679223ca" "07b85b31-ca6a-11ed-8caa-efa6679223ca" "07b85b34-ca6a-11ed-8caa-efa6679223ca" "07b7bf0a-ca6a-11ed-8caa-efa6679223ca" "07b7bef0-ca6a-11ed-8caa-efa6679223ca" "07b7bf11-ca6a-11ed-8caa-efa6679223ca" "07b7bf14-ca6a-11ed-8caa-efa6679223ca" "07b7beee-ca6a-11ed-8caa-efa6679223ca" "07b7bf05-ca6a-11ed-8caa-efa6679223ca" "07b7bee4-ca6a-11ed-8caa-efa6679223ca" "07b85b30-ca6a-11ed-8caa-efa6679223ca")}} :block/updated-at 1709937459304 :block/created-at 1679679225782 -:block/type ["whiteboard"] +:block/type "whiteboard" :block/name "test whiteboard" :block/title "Test Whiteboard"})} diff --git a/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/block tests.edn b/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/block tests.edn index 70cdde6710..ab26b65f39 100644 --- a/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/block tests.edn +++ b/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"})} diff --git a/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/publishing test.edn b/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/publishing test.edn index 9f15910a61..9ee44456bd 100644 --- a/deps/graph-parser/test/resources/exporter-test-graph/whiteboards/publishing test.edn +++ b/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"})} diff --git a/deps/outliner/src/logseq/outliner/property.cljs b/deps/outliner/src/logseq/outliner/property.cljs index dca8a8c876..02ecabcd06 100644 --- a/deps/outliner/src/logseq/outliner/property.cljs +++ b/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]] diff --git a/src/main/frontend/common_keywords.cljs b/src/main/frontend/common_keywords.cljs index 6e1f378a55..f9b621c9a5 100644 --- a/src/main/frontend/common_keywords.cljs +++ b/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") diff --git a/src/main/frontend/components/all_pages.cljs b/src/main/frontend/components/all_pages.cljs index 8c243c5f23..b3c9083584 100644 --- a/src/main/frontend/components/all_pages.cljs +++ b/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 diff --git a/src/main/frontend/components/db_based/page.cljs b/src/main/frontend/components/db_based/page.cljs index 9d16911324..7c31bd7298 100644 --- a/src/main/frontend/components/db_based/page.cljs +++ b/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 diff --git a/src/main/frontend/components/imports.cljs b/src/main/frontend/components/imports.cljs index 77fd516af3..28a23ae8e8 100644 --- a/src/main/frontend/components/imports.cljs +++ b/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 diff --git a/src/main/frontend/components/page.cljs b/src/main/frontend/components/page.cljs index aaf522bbed..b9ebe62527 100644 --- a/src/main/frontend/components/page.cljs +++ b/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 diff --git a/src/main/frontend/components/page_menu.cljs b/src/main/frontend/components/page_menu.cljs index 0e4186e78d..9600b6e48c 100644 --- a/src/main/frontend/components/page_menu.cljs +++ b/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) diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index 4294aa4cab..cea099f3c4 100644 --- a/src/main/frontend/components/property.cljs +++ b/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/> (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] diff --git a/src/main/frontend/handler/whiteboard.cljs b/src/main/frontend/handler/whiteboard.cljs index 7c8c4a4172..eaba9869ff 100644 --- a/src/main/frontend/handler/whiteboard.cljs +++ b/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)} diff --git a/src/main/frontend/worker/db/migrate.cljs b/src/main/frontend/worker/db/migrate.cljs index a64340762e..fe0f88ff23 100644 --- a/src/main/frontend/worker/db/migrate.cljs +++ b/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 []}] diff --git a/src/main/frontend/worker/export.cljs b/src/main/frontend/worker/export.cljs index 41229e688d..92cc1e2a6e 100644 --- a/src/main/frontend/worker/export.cljs +++ b/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 diff --git a/src/main/frontend/worker/file.cljs b/src/main/frontend/worker/file.cljs index 23d75c6e88..3273096092 100644 --- a/src/main/frontend/worker/file.cljs +++ b/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))] diff --git a/src/main/frontend/worker/file/core.cljs b/src/main/frontend/worker/file/core.cljs index 3818a2eeeb..555970b55f 100644 --- a/src/main/frontend/worker/file/core.cljs +++ b/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))}) diff --git a/src/main/frontend/worker/handler/page.cljs b/src/main/frontend/worker/handler/page.cljs index 5f063fca38..12a11bde7e 100644 --- a/src/main/frontend/worker/handler/page.cljs +++ b/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) diff --git a/src/main/frontend/worker/handler/page/db_based/page.cljs b/src/main/frontend/worker/handler/page/db_based/page.cljs index 05b2704b65..c128928b50 100644 --- a/src/main/frontend/worker/handler/page/db_based/page.cljs +++ b/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 %]))) diff --git a/src/main/frontend/worker/handler/page/file_based/page.cljs b/src/main/frontend/worker/handler/page/file_based/page.cljs index 6676e8837e..f555282efe 100644 --- a/src/main/frontend/worker/handler/page/file_based/page.cljs +++ b/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)})) diff --git a/src/main/frontend/worker/handler/page/file_based/rename.cljs b/src/main/frontend/worker/handler/page/file_based/rename.cljs index 6320880cb6..d32f038954 100644 --- a/src/main/frontend/worker/handler/page/file_based/rename.cljs +++ b/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?) diff --git a/src/main/frontend/worker/rtc/asset_db_listener.cljs b/src/main/frontend/worker/rtc/asset_db_listener.cljs index 105de4c193..092d666efb 100644 --- a/src/main/frontend/worker/rtc/asset_db_listener.cljs +++ b/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]))))) diff --git a/src/main/frontend/worker/rtc/db_listener.cljs b/src/main/frontend/worker/rtc/db_listener.cljs index cd3ecab0a8..2d6672fc67 100644 --- a/src/main/frontend/worker/rtc/db_listener.cljs +++ b/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*)] diff --git a/src/main/frontend/worker/rtc/remote_update.cljs b/src/main/frontend/worker/rtc/remote_update.cljs index 27c70f896e..8c665d59fb 100644 --- a/src/main/frontend/worker/rtc/remote_update.cljs +++ b/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 [], false []}" [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)] diff --git a/src/main/frontend/worker/search.cljs b/src/main/frontend/worker/search.cljs index 451c17a340..f0904ce274 100644 --- a/src/main/frontend/worker/search.cljs +++ b/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 diff --git a/src/test/frontend/worker/rtc/client_test.cljs b/src/test/frontend/worker/rtc/client_test.cljs index 24fa8711e5..fcf6cdd7ca 100644 --- a/src/test/frontend/worker/rtc/client_test.cljs +++ b/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"}])]