Remove repeated/duplucated lookups on start-undo-transaction

This commit is contained in:
Andrey Antukh 2025-08-25 10:20:53 +02:00 committed by Pablo Alba
parent 6eeb55fb88
commit c9393c0cfb

View File

@ -162,14 +162,12 @@
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
(log/info :hint "start-undo-transaction") (log/info :hint "start-undo-transaction")
;; We commit the old transaction before starting the new one
(let [current-tx (get-in state [:workspace-undo :transaction]) (update state :workspace-undo
pending-tx (get-in state [:workspace-undo :transactions-pending])] (fn [undo-state]
(cond-> state (-> undo-state
(nil? current-tx) (assoc-in [:workspace-undo :transaction] empty-tx) (update :transaction #(d/nilv % empty-tx))
(nil? pending-tx) (assoc-in [:workspace-undo :transactions-pending] #{id}) (update :transactions-pending assoc id (ct/now))))))
(some? pending-tx) (update-in [:workspace-undo :transactions-pending] conj id)
:always (update-in [:workspace-undo :transactions-pending-ts] assoc id (ct/now)))))
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]