enhance: don't update :block/updated-at when collapsing or expanding

This commit is contained in:
Tienson Qin
2025-04-16 17:57:29 +08:00
parent 62514b74d8
commit d378c7e754
2 changed files with 16 additions and 11 deletions

View File

@@ -221,7 +221,7 @@
(extend-type Entity
otree/INode
(-save [this *txs-state db repo _date-formatter {:keys [retract-attributes? retract-attributes]
(-save [this *txs-state db repo _date-formatter {:keys [retract-attributes? retract-attributes outliner-op]
:or {retract-attributes? true}}]
(assert (ds/outliner-txs-state? *txs-state)
"db should be satisfied outliner-tx-state?")
@@ -233,12 +233,16 @@
data)
db-based?
(dissoc :block/properties))
m* (-> data'
(dissoc :block/children :block/meta :block/unordered
:block.temp/ast-title :block.temp/ast-body :block/level :block.temp/fully-loaded?)
common-util/remove-nils
block-with-updated-at
(fix-tag-ids db {:db-graph? db-based?}))
collapse-or-expand? (= outliner-op :collapse-expand-blocks)
m* (cond->
(-> data'
(dissoc :block/children :block/meta :block/unordered
:block.temp/ast-title :block.temp/ast-body :block/level :block.temp/fully-loaded?)
common-util/remove-nils
(fix-tag-ids db {:db-graph? db-based?}))
(not collapse-or-expand?)
block-with-updated-at)
db-id (:db/id this)
block-uuid (:block/uuid this)
eid (or db-id (when block-uuid [:block/uuid block-uuid]))
@@ -292,7 +296,8 @@
retract-attributes)))))))
;; Update block's page attributes
(update-page-when-save-block *txs-state block-entity m)
(when-not collapse-or-expand?
(update-page-when-save-block *txs-state block-entity m))
;; Remove orphaned refs from block
(when (and (:block/title m) (not= (:block/title m) (:block/title block-entity)))
(remove-orphaned-refs-when-save db *txs-state block-entity m {:db-graph? db-based?})))

View File

@@ -77,8 +77,8 @@
(def edit-block! block-handler/edit-block!)
(defn- outliner-save-block!
[block]
(outliner-op/save-block! block))
[block & {:as opts}]
(outliner-op/save-block! block opts))
(defn get-block-own-order-list-type
[block]
@@ -3642,7 +3642,7 @@
(when-not (= current-value value)
(let [block {:block/uuid block-id
:block/collapsed? value}]
(outliner-save-block! block)))))))
(outliner-save-block! block {:outliner-op :collapse-expand-blocks})))))))
(doseq [block-id block-ids]
(state/set-collapsed-block! block-id value)))))