🐛 Fix race condition on trying to persist file changes after going to dashboard

This commit is contained in:
Elena Torro 2026-05-19 13:51:59 +02:00
parent ee6489b202
commit 2a9879139f
2 changed files with 7 additions and 4 deletions

View File

@ -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

View File

@ -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}]