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