From d3148e1a10649518eab46782f5182f55573b0a76 Mon Sep 17 00:00:00 2001 From: Luis de Dios Date: Mon, 1 Jun 2026 10:08:40 +0200 Subject: [PATCH] :bug: Fix add modal confirmation when clicking restore from saved version preview (#9804) --- .../src/app/main/data/workspace/versions.cljs | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/frontend/src/app/main/data/workspace/versions.cljs b/frontend/src/app/main/data/workspace/versions.cljs index 67b10ca760..57ccb4a25f 100644 --- a/frontend/src/app/main/data/workspace/versions.cljs +++ b/frontend/src/app/main/data/workspace/versions.cljs @@ -176,6 +176,25 @@ ;; RESTORE VERSION EVENTS ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +(defn exit-preview + "Exit from preview mode and reload the live file data" + [] + (ptk/reify ::exit-preview + ptk/UpdateEvent + (update [_ state] + (let [backup (dm/get-in state [:workspace-versions :backup])] + (-> state + (update :workspace-versions dissoc :backup) + (update :workspace-global dissoc :read-only? :preview-id) + (update :files assoc (:id backup) backup)))) + + ptk/WatchEvent + (watch [_ state _] + (let [file-id (:current-file-id state) + page-id (:current-page-id state)] + + (rx/of (dwpg/initialize-page file-id page-id)))))) + (defn- restore-version [id] (assert (uuid? id) "expected valid uuid for `id`") @@ -211,6 +230,7 @@ :cancel {:label (tr "workspace.updates.dismiss") :callback #(do (rx/push! output-s (ntf/hide :tag :restore-dialog)) + (rx/push! output-s (exit-preview)) (rx/end! output-s))} :accept {:label (tr "labels.restore") :callback #(do @@ -232,25 +252,6 @@ (update [_ state] (update state :files assoc id snapshot)))) -(defn exit-preview - "Exit from preview mode and reload the live file data" - [] - (ptk/reify ::exit-preview - ptk/UpdateEvent - (update [_ state] - (let [backup (dm/get-in state [:workspace-versions :backup])] - (-> state - (update :workspace-versions dissoc :backup) - (update :workspace-global dissoc :read-only? :preview-id) - (update :files assoc (:id backup) backup)))) - - ptk/WatchEvent - (watch [_ state _] - (let [file-id (:current-file-id state) - page-id (:current-page-id state)] - - (rx/of (dwpg/initialize-page file-id page-id)))))) - (defn enter-preview "Load a snapshot into the workspace for read-only preview without modifying any database state. Sets a read-only flag so no changes @@ -291,7 +292,7 @@ :accept {:label (tr "labels.restore") :callback #(do (rx/push! output-s (ntf/hide)) - (rx/push! output-s (restore-version id)) + (rx/push! output-s (enter-restore id)) (rx/end! output-s))} :tag :preview-dialog))