Просмотр исходного кода

fix: remove unused :block/type "object"

fixes LOG-2914
Gabriel Horner 2 лет назад
Родитель
Сommit
cca80e37a7

+ 3 - 22
deps/db/src/logseq/db/frontend/malli_schema.cljs

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

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

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

+ 1 - 1
src/main/frontend/db/rtc/const.cljs

@@ -19,7 +19,7 @@
 (def general-attr-set
 (def general-attr-set
   (into #{} (map first) general-attrs-schema-coll))
   (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
 (def to-ws-op-schema
   [:multi {:dispatch first :decode/string #(update % 0 keyword)}
   [:multi {:dispatch first :decode/string #(update % 0 keyword)}

+ 1 - 2
src/main/frontend/db/rtc/full_upload_download_graph.cljs

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

+ 1 - 3
src/main/frontend/handler/db_based/property.cljs

@@ -439,9 +439,7 @@
                               :block/tags)]
                               :block/tags)]
               (when property-value-id
               (when property-value-id
                 (db/transact! repo
                 (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})))
                               {:outliner-op :save-block})))
             (if (= :many (:cardinality schema))
             (if (= :many (:cardinality schema))
               (let [properties (:block/properties block)
               (let [properties (:block/properties block)

+ 5 - 10
src/main/frontend/modules/outliner/core.cljs

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