mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-11 16:30:16 -06:00
Control channel: a failed app.open answers with the error and opens no alert
An alert waits for a click that a control client can't give. app.open reports the error in its response, as engine.execute does; File › Open, drops and the command line still show the alert.
This commit is contained in:
@@ -334,7 +334,7 @@ pub fn handle(app: &mut DesignApp, ctx: &egui::Context, req: &ControlRequest) ->
|
||||
None => ok(json!({"width": img.width, "height": img.height, "pngBase64": designcraft_engine::cmd::base64_encode(&png)})),
|
||||
}
|
||||
}
|
||||
"app.open" => wrap(app.open_file("file.open", json!({"path": s("path")}))),
|
||||
"app.open" => wrap(app.run("file.open", json!({"path": s("path")}))),
|
||||
"app.save" => wrap(app.run("file.save", json!({"path": s("path")}))),
|
||||
"app.export" => wrap(app.run("app.exportPng", json!({"path": s("path"), "page": p.get("page"), "scale": p.get("scale")}))),
|
||||
"app.quit" => {
|
||||
|
||||
@@ -977,5 +977,10 @@ mod tests {
|
||||
assert!(app.run("file.open", json!({"path": "/nonexistent/x.designcraft"})).is_err());
|
||||
assert!(app.ui.dialog.is_none(), "a scripted file.open doesn't raise an alert");
|
||||
assert!(!app.ui.status.is_empty());
|
||||
// The control channel's app.open answers with the error; no alert waits for a click.
|
||||
let (req, _rx) = control::ControlRequest::new("app.open", json!({"path": "/nonexistent/x.designcraft"}));
|
||||
let control::Outcome::Done(r) = control::handle(&mut app, &egui::Context::default(), &req) else { panic!("app.open answers") };
|
||||
assert_eq!(r["ok"], json!(false), "{r}");
|
||||
assert!(app.ui.dialog.is_none(), "a control-channel app.open doesn't raise an alert");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user