From c9393c0cfb9f09bab83fa32cb4d6e67237367ab3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 25 Aug 2025 10:20:53 +0200 Subject: [PATCH] :zap: Remove repeated/duplucated lookups on start-undo-transaction --- frontend/src/app/main/data/workspace/undo.cljs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/main/data/workspace/undo.cljs b/frontend/src/app/main/data/workspace/undo.cljs index fe9f26bcad..16e37114e4 100644 --- a/frontend/src/app/main/data/workspace/undo.cljs +++ b/frontend/src/app/main/data/workspace/undo.cljs @@ -162,14 +162,12 @@ ptk/UpdateEvent (update [_ state] (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]) - pending-tx (get-in state [:workspace-undo :transactions-pending])] - (cond-> state - (nil? current-tx) (assoc-in [:workspace-undo :transaction] empty-tx) - (nil? pending-tx) (assoc-in [:workspace-undo :transactions-pending] #{id}) - (some? pending-tx) (update-in [:workspace-undo :transactions-pending] conj id) - :always (update-in [:workspace-undo :transactions-pending-ts] assoc id (ct/now))))) + + (update state :workspace-undo + (fn [undo-state] + (-> undo-state + (update :transaction #(d/nilv % empty-tx)) + (update :transactions-pending assoc id (ct/now)))))) ptk/WatchEvent (watch [_ _ _]