From 2a9879139ffdeea50d1f51892bde4712acefd588 Mon Sep 17 00:00:00 2001 From: Elena Torro Date: Tue, 19 May 2026 13:51:59 +0200 Subject: [PATCH] :bug: Fix race condition on trying to persist file changes after going to dashboard --- frontend/src/app/main/data/changes.cljs | 3 ++- frontend/src/app/main/data/persistence.cljs | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/main/data/changes.cljs b/frontend/src/app/main/data/changes.cljs index e91fcf0f4e..720c285017 100644 --- a/frontend/src/app/main/data/changes.cljs +++ b/frontend/src/app/main/data/changes.cljs @@ -209,7 +209,8 @@ permissions (get state :permissions)] ;; Prevent commit changes by a viewer team member (it really should never happen) - (when (:can-edit permissions) + ;; or if there is no file + (when (and (:can-edit permissions) file-id) (log/trace :hint "commit-changes" :redo-changes redo-changes) (let [selected (dm/get-in state [:workspace-local :selected])] (rx/of (-> params diff --git a/frontend/src/app/main/data/persistence.cljs b/frontend/src/app/main/data/persistence.cljs index c90c423f96..3f4bb0eefc 100644 --- a/frontend/src/app/main/data/persistence.cljs +++ b/frontend/src/app/main/data/persistence.cljs @@ -121,9 +121,11 @@ :features features} permissions (:permissions state)] - ;; Prevent saving changes when in version preview (read-only) mode - ;; or when the user does not have edition permission. - (when (and (:can-edit permissions) + ;; Prevent saving changes when in version preview (read-only) mode, + ;; when the user does not have edition permission, or when file-id is nil + ;; (race condition: navigation can clear :current-file-id before commit fires). + (when (and file-id + (:can-edit permissions) (not (get-in state [:workspace-global :read-only?]))) (->> (rp/cmd! :update-file params) (rx/mapcat (fn [{:keys [revn lagged] :as response}]