fix(actions): authorize confirmed edits with captured dialog fields

This commit is contained in:
yoriswind committed 2026-11-04 20:42:30 -08:00
1 parent 2c66f80520
commit dfb6d608cf
3 files changed
+11 -6

No files matched your search

+1 -1
View File
@@ -58,7 +58,7 @@ pub(crate) fn ensure_filter_preview(app: &mut PhotocraftApp, idx: usize, ctx: &e
}
params = crate::select_mask_view::request_params(&d.fields, params);
}
crate::actions::authorize_preview(app, d.id, &cmd, &params).ok()?;
crate::actions::authorize_dialog_edit(app, d.id, &d.fields, &cmd, &params).ok()?;
let st = app.session.documents().get(idx)?;
let k = filter_preview_factor(app, &st.doc, &cmd, &params);
let request = crate::filter_dialog::FilterPreviewKey {
+1 -1
View File
@@ -192,7 +192,7 @@ fn dialog(app: &PhotocraftApp) -> Option<(String, Value, bool)> {
let kind = d.fields.get("__adjust")?.as_str()?.to_string();
let preview = d.fields.get("__preview").and_then(Value::as_bool).unwrap_or(true);
let params = crate::filter_dialog::params_of(&d.fields);
crate::actions::authorize_preview(app, d.id, &format!("image.adjustments.{kind}"), &params).ok()?;
crate::actions::authorize_dialog_edit(app, d.id, &d.fields, &format!("image.adjustments.{kind}"), &params).ok()?;
Some((kind, params, preview))
}
+9 -4
View File
@@ -1395,11 +1395,16 @@ pub(crate) fn validate_editor(app: &PhotocraftApp, dialog: u64, fields: &serde_j
Ok(())
}
/// Record Again and the canonical frame both retain their preview authority and document.
pub(crate) fn authorize_preview(app: &PhotocraftApp, dialog: u64, command: &str, params: &Value) -> Result<(), String> {
/// Authorize a live preview or a confirmed edit using the owning dialog's fields.
pub(crate) fn authorize_dialog_edit(
app: &PhotocraftApp,
dialog: u64,
fields: &serde_json::Map<String, Value>,
command: &str,
params: &Value,
) -> Result<(), String> {
record_again::authorize_preview(app, dialog, command, params)?;
if let Some(paused) = app.paused_playbacks.paused.values().find(|paused| paused.dialog == dialog) {
let fields = &app.ui.dialogs.iter().find(|value| value.id == dialog).ok_or("the action step dialog closed")?.fields;
validate_editor(app, dialog, fields)?;
if fields.get("__command").and_then(Value::as_str) != Some(command) {
return Err("the paused action preview command changed".into());
@@ -1421,7 +1426,7 @@ pub(crate) fn run_dialog_command(
) -> Result<Value, String> {
with_step_gate(app, fields, Some(dialog), |app| {
validate_editor(app, dialog, fields)?;
authorize_preview(app, dialog, command, &params)?;
authorize_dialog_edit(app, dialog, fields, command, &params)?;
run_step_dialog(app, fields, command, params)
})
}