fix: remove unused :block/type "object"

fixes LOG-2914
This commit is contained in:
Gabriel Horner
2023-11-16 14:50:21 -05:00
parent 834c466590
commit cca80e37a7
6 changed files with 12 additions and 39 deletions

View File

@@ -88,7 +88,7 @@
"Common attributes for pages"
[[:block/name :string]
[:block/original-name :string]
[:block/type {:optional true} [:enum #{"property"} #{"class"} #{"object"} #{"whiteboard"} #{"hidden"}]]
[:block/type {:optional true} [:enum #{"property"} #{"class"} #{"whiteboard"} #{"hidden"}]]
[:block/journal? :boolean]
[:block/alias {:optional true} [:set :int]]
;; TODO: Should this be here or in common?
@@ -98,21 +98,14 @@
(vec
(concat
[:map
;; Only for linked pages
[:block/collapsed? {:optional true} :boolean]
;; journal-day is only set for journal pages
[:block/journal-day {:optional true} :int]
[:block/namespace {:optional true} :int]]
page-attrs
page-or-block-attrs)))
(def object-page
(vec
(concat
[:map
[:block/collapsed? {:optional true} :boolean]
[:block/tags [:set :int]]]
page-attrs
(remove #(= :block/tags (first %)) page-or-block-attrs))))
(def class-page
(vec
(concat
@@ -183,7 +176,6 @@
[:multi {:dispatch :block/type}
[#{"property"} property-page]
[#{"class"} class-page]
[#{"object"} object-page]
[#{"hidden"} hidden-page]
[:malli.core/default normal-page]])
@@ -212,16 +204,6 @@
[:block/priority {:optional true} :string]
[:block/collapsed? {:optional true} :boolean]])
(def object-block
"A normal block with tags"
(vec
(concat
[:map]
[[:block/type [:= #{"object"}]]
[:block/tags [:set :int]]]
block-attrs
(remove #(= :block/tags (first %)) page-or-block-attrs))))
(def whiteboard-block
"A (shape) block for whiteboard"
(vec
@@ -260,7 +242,6 @@
"A block has content and a page"
[:or
normal-block
object-block
closed-value-block
whiteboard-block])

View File

@@ -1338,7 +1338,7 @@
[:div.r.flex.items-center.justify-between
[:div
(ui/select (->> (if (config/db-based-graph? current-repo)
["" "class" "property" "object" "whiteboard"]
["" "class" "property" "whiteboard"]
["" "whiteboard"])
(map (fn [block-type]
{:label (if (seq block-type) (string/capitalize block-type) "Filter by page type")

View File

@@ -19,7 +19,7 @@
(def general-attr-set
(into #{} (map first) general-attrs-schema-coll))
(def block-type-schema [:enum "property" "class" "whiteboard" "object" "hidden" "closed value"])
(def block-type-schema [:enum "property" "class" "whiteboard" "hidden" "closed value"])
(def to-ws-op-schema
[:multi {:dispatch first :decode/string #(update % 0 keyword)}

View File

@@ -62,8 +62,7 @@
{:block-type/property "property"
:block-type/class "class"
:block-type/whiteboard "whiteboard"
:block-type/macros "macros"
:block-type/object "object"})
:block-type/macros "macros"})
(defn- replace-db-id-with-temp-id

View File

@@ -439,9 +439,7 @@
:block/tags)]
(when property-value-id
(db/transact! repo
(cond-> [[:db/retract (:db/id block) attribute property-value-id]]
(and :block/tags (= 1 (count (:block/tags block))))
(conj [:db/retract (:db/id block) :block/type "object"]))
[[:db/retract (:db/id block) attribute property-value-id]]
{:outliner-op :save-block})))
(if (= :many (:cardinality schema))
(let [properties (:block/properties block)

View File

@@ -150,7 +150,7 @@
(vector :db.fn/retractEntity (:db/id %)))
(:block/macros block-entity)))))))
(defn- create-object-when-save
(defn- create-linked-page-when-save
[txs-state block-entity m structured-tags?]
(if structured-tags?
(let [content (state/get-edit-content)
@@ -158,7 +158,7 @@
sanity-linked-page (some-> linked-page util/page-name-sanity-lc)
linking-page? (and (not (string/blank? sanity-linked-page))
@(:editor/create-page? @state/state))]
(if linking-page?
(when linking-page?
(let [existing-ref-id (some (fn [r]
(when (= sanity-linked-page (:block/name r))
(:block/uuid r)))
@@ -178,17 +178,12 @@
(concat txs
[(assoc page-m
:block/tags (:block/tags m)
:block/format :markdown
:block/type "object")
:block/format :markdown)
{:db/id (:db/id block-entity)
:block/content ""
:block/refs []
:block/link [:block/uuid (:block/uuid page-m)]}]
merge-tx))))
(swap! txs-state (fn [txs]
(concat txs
[{:db/id (:db/id block-entity)
:block/type "object"}])))))
merge-tx))))))
(reset! (:editor/create-page? @state/state) false)))
(defn rebuild-block-refs
@@ -337,7 +332,7 @@
(swap! txs-state conj
(dissoc m :db/other-tx)))
(create-object-when-save txs-state block-entity m structured-tags?)
(create-linked-page-when-save txs-state block-entity m structured-tags?)
(rebuild-refs repo txs-state block-entity m)