mirror of https://github.com/logseq/logseq
Rename temp :block keys to be explicit about their use
:block is a heavily used namespace. We should at least be explicit about keys that aren't being transactedpull/9525/head
parent
33285a354d
commit
df2edd44ac
|
@ -208,7 +208,7 @@
|
||||||
pages (remove nil? pages)
|
pages (remove nil? pages)
|
||||||
pages (map (fn [page] (assoc page :block/uuid (d/squuid))) pages)
|
pages (map (fn [page] (assoc page :block/uuid (d/squuid))) pages)
|
||||||
blocks (->> (remove nil? blocks)
|
blocks (->> (remove nil? blocks)
|
||||||
(map (fn [b] (dissoc b :block/title :block/body :block/level :block/children :block/meta :block/anchor))))]
|
(map (fn [b] (dissoc b :block/title :block/body :block/level :block/children :block/meta))))]
|
||||||
[pages blocks])
|
[pages blocks])
|
||||||
(catch :default e
|
(catch :default e
|
||||||
(log/error :exception e))))
|
(log/error :exception e))))
|
||||||
|
|
|
@ -1792,8 +1792,8 @@
|
||||||
(or
|
(or
|
||||||
(and empty-content?
|
(and empty-content?
|
||||||
(not edit?)
|
(not edit?)
|
||||||
(not (:block/top? block))
|
(not (:block.temp/top? block))
|
||||||
(not (:block/bottom? block))
|
(not (:block.temp/bottom? block))
|
||||||
(not (util/react *control-show?)))
|
(not (util/react *control-show?)))
|
||||||
(and doc-mode?
|
(and doc-mode?
|
||||||
(not collapsed?)
|
(not collapsed?)
|
||||||
|
@ -2780,7 +2780,8 @@
|
||||||
block (if ref?
|
block (if ref?
|
||||||
(merge block (db/sub-block (:db/id block)))
|
(merge block (db/sub-block (:db/id block)))
|
||||||
block)
|
block)
|
||||||
{:block/keys [uuid children pre-block? top? refs level format content properties]} block
|
{:block/keys [uuid children pre-block? refs level format content properties]} block
|
||||||
|
{:block.temp/keys [top?]} block
|
||||||
config (if navigated? (assoc config :id (str navigating-block)) config)
|
config (if navigated? (assoc config :id (str navigating-block)) config)
|
||||||
block (merge block (block/parse-title-and-body uuid format pre-block? content))
|
block (merge block (block/parse-title-and-body uuid format pre-block? content))
|
||||||
blocks-container-id (:blocks-container-id config)
|
blocks-container-id (:blocks-container-id config)
|
||||||
|
@ -2923,7 +2924,7 @@
|
||||||
|
|
||||||
:should-update (fn [old-state new-state]
|
:should-update (fn [old-state new-state]
|
||||||
(let [compare-keys [:block/uuid :block/content :block/parent :block/collapsed?
|
(let [compare-keys [:block/uuid :block/content :block/parent :block/collapsed?
|
||||||
:block/properties :block/left :block/children :block/_refs :block/bottom? :block/top?]
|
:block/properties :block/left :block/children :block/_refs :block.temp/bottom? :block.temp/top?]
|
||||||
config-compare-keys [:show-cloze? :own-order-list-type :own-order-list-index]
|
config-compare-keys [:show-cloze? :own-order-list-type :own-order-list-index]
|
||||||
b1 (second (:rum/args old-state))
|
b1 (second (:rum/args old-state))
|
||||||
b2 (second (:rum/args new-state))
|
b2 (second (:rum/args new-state))
|
||||||
|
@ -3317,8 +3318,8 @@
|
||||||
[config blocks idx item]
|
[config blocks idx item]
|
||||||
(let [item (->
|
(let [item (->
|
||||||
(dissoc item :block/meta)
|
(dissoc item :block/meta)
|
||||||
(assoc :block/top? (zero? idx)
|
(assoc :block.temp/top? (zero? idx)
|
||||||
:block/bottom? (= (count blocks) (inc idx))))
|
:block.temp/bottom? (= (count blocks) (inc idx))))
|
||||||
config (assoc config :block/uuid (:block/uuid item))]
|
config (assoc config :block/uuid (:block/uuid item))]
|
||||||
(rum/with-key (block-container config item)
|
(rum/with-key (block-container config item)
|
||||||
(str (:blocks-container-id config) "-" (:block/uuid item)))))
|
(str (:blocks-container-id config) "-" (:block/uuid item)))))
|
||||||
|
|
|
@ -341,8 +341,8 @@
|
||||||
(select-keys properties (property/hidden-properties))
|
(select-keys properties (property/hidden-properties))
|
||||||
(:block/properties block))]
|
(:block/properties block))]
|
||||||
(-> block
|
(-> block
|
||||||
(dissoc :block/top?
|
(dissoc :block.temp/top?
|
||||||
:block/bottom?)
|
:block.temp/bottom?)
|
||||||
(assoc :block/content content
|
(assoc :block/content content
|
||||||
:block/properties new-properties)
|
:block/properties new-properties)
|
||||||
(merge (if level {:block/level level} {})))))
|
(merge (if level {:block/level level} {})))))
|
||||||
|
@ -826,7 +826,7 @@
|
||||||
(let [prev-block' (if (seq (:block/_refs block-e))
|
(let [prev-block' (if (seq (:block/_refs block-e))
|
||||||
(assoc prev-block
|
(assoc prev-block
|
||||||
:block/uuid (:block/uuid block)
|
:block/uuid (:block/uuid block)
|
||||||
:block/additional-properties (:block/properties block))
|
:block.temp/additional-properties (:block/properties block))
|
||||||
prev-block)]
|
prev-block)]
|
||||||
(delete-block-aux! block delete-children?)
|
(delete-block-aux! block delete-children?)
|
||||||
(save-block! repo prev-block' new-content {:editor/op :delete}))
|
(save-block! repo prev-block' new-content {:editor/op :delete}))
|
||||||
|
@ -2646,7 +2646,7 @@
|
||||||
edit-block' (if next-block-has-refs?
|
edit-block' (if next-block-has-refs?
|
||||||
(assoc edit-block
|
(assoc edit-block
|
||||||
:block/uuid (:block/uuid next-block)
|
:block/uuid (:block/uuid next-block)
|
||||||
:block/additional-properties (dissoc (:block/properties next-block) :block/uuid))
|
:block.temp/additional-properties (dissoc (:block/properties next-block) :block/uuid))
|
||||||
edit-block)]
|
edit-block)]
|
||||||
(outliner-tx/transact! transact-opts
|
(outliner-tx/transact! transact-opts
|
||||||
(delete-block-aux! next-block false)
|
(delete-block-aux! next-block false)
|
||||||
|
@ -2691,7 +2691,7 @@
|
||||||
repo (state/get-current-repo)
|
repo (state/get-current-repo)
|
||||||
top-block? (= (:block/left block) (:block/page block))
|
top-block? (= (:block/left block) (:block/page block))
|
||||||
single-block? (inside-of-single-block (.-target e))
|
single-block? (inside-of-single-block (.-target e))
|
||||||
root-block? (= (:block/container block) (str (:block/uuid block)))]
|
root-block? (= (:block.temp/container block) (str (:block/uuid block)))]
|
||||||
(mark-last-input-time! repo)
|
(mark-last-input-time! repo)
|
||||||
(cond
|
(cond
|
||||||
(not= selected-start selected-end)
|
(not= selected-start selected-end)
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
(assert (ds/outliner-txs-state? txs-state)
|
(assert (ds/outliner-txs-state? txs-state)
|
||||||
"db should be satisfied outliner-tx-state?")
|
"db should be satisfied outliner-tx-state?")
|
||||||
(let [m (-> (:data this)
|
(let [m (-> (:data this)
|
||||||
(dissoc :block/children :block/meta :block/top? :block/bottom?
|
(dissoc :block/children :block/meta :block.temp/top? :block.temp/bottom?
|
||||||
:block/title :block/body :block/level)
|
:block/title :block/body :block/level)
|
||||||
(gp-util/remove-nils))
|
(gp-util/remove-nils))
|
||||||
m (if (state/enable-block-timestamps?) (block-with-timestamps m) m)
|
m (if (state/enable-block-timestamps?) (block-with-timestamps m) m)
|
||||||
|
|
|
@ -126,9 +126,12 @@
|
||||||
(let [txs (remove-nil-from-transaction txs)
|
(let [txs (remove-nil-from-transaction txs)
|
||||||
txs (map (fn [m] (if (map? m)
|
txs (map (fn [m] (if (map? m)
|
||||||
(dissoc m
|
(dissoc m
|
||||||
:block/children :block/meta :block/top? :block/bottom? :block/anchor
|
;; TODO: Move these attributes to :block.temp when the risk is lower
|
||||||
:block/title :block/body :block/level :block/container :db/other-tx
|
:block/children :block/meta :block/title :block/body :block/level
|
||||||
:block/additional-properties)
|
:db/other-tx
|
||||||
|
;; :block.temp is for temporary block attributes that aren't transacted
|
||||||
|
:block.temp/container :block.temp/top? :block.temp/bottom?
|
||||||
|
:block.temp/additional-properties)
|
||||||
m)) txs)
|
m)) txs)
|
||||||
txs (cond-> txs
|
txs (cond-> txs
|
||||||
(:uuid-changed opts)
|
(:uuid-changed opts)
|
||||||
|
|
|
@ -1808,7 +1808,7 @@ Similar to re-frame subscriptions"
|
||||||
container (util/get-block-container block-element)
|
container (util/get-block-container block-element)
|
||||||
block (if container
|
block (if container
|
||||||
(assoc block
|
(assoc block
|
||||||
:block/container (gobj/get container "id"))
|
:block.temp/container (gobj/get container "id"))
|
||||||
block)
|
block)
|
||||||
content (string/trim (or content ""))]
|
content (string/trim (or content ""))]
|
||||||
(swap! state
|
(swap! state
|
||||||
|
|
Loading…
Reference in New Issue