feat: ask whether a reply carries the sender's frontmatter

This commit is contained in:
randogoth 2026-10-03 17:58:30 +03:00
parent dacbc9de38
commit cda8985218
4 changed files with 167 additions and 10 deletions

View file

@ -1649,6 +1649,7 @@ fn render(model: &Carrier, w: &mut CarrierWidgets, sender: &ComponentSender<Carr
match (&model.dialog, w.dialog.is_some()) {
(Some(dialog), false) => {
let rotating = matches!(dialog, Dialog::Rotate);
let replying = matches!(dialog, Dialog::Reply { .. });
let alert = match dialog {
Dialog::Delete { kept, .. } => {
let alert = adw::AlertDialog::new(
@ -1681,17 +1682,41 @@ fn render(model: &Carrier, w: &mut CarrierWidgets, sender: &ComponentSender<Carr
alert.set_response_appearance("rotate", adw::ResponseAppearance::Destructive);
alert
}
Dialog::Reply { rows, .. } => {
let list = rows
.iter()
.map(String::as_str)
.collect::<Vec<_>>()
.join("\n");
let alert = adw::AlertDialog::new(
Some("Carry the sender's fields into the reply?"),
Some(&format!(
"This message carries its own frontmatter:\n\n{list}\n\nReply with copies of these fields, or start with none. The fields stay editable either way."
)),
);
alert.add_response("cancel", "Cancel Reply");
alert.add_response("without", "Reply Without");
alert.add_response("copy", "Copy Fields");
alert.set_response_appearance("copy", adw::ResponseAppearance::Suggested);
alert
}
};
// The reply dialog carries its own default: Enter answers the
// question instead of cancelling the reply the user asked for.
let close_default = if replying { "without" } else { "cancel" };
alert.set_close_response("cancel");
alert.set_default_response(Some("cancel"));
alert.set_default_response(Some(close_default));
let response_sender = sender.clone();
alert.connect_response(None, move |_, response| {
response_sender.input(match (rotating, response) {
(true, "rotate") => Message::RotateConfirmed,
(true, _) => Message::RotateCancelled,
(false, "here") => Message::DeleteConfirmed(false),
(false, "everywhere") => Message::DeleteConfirmed(true),
(false, _) => Message::DeleteCancelled,
response_sender.input(match (rotating, replying, response) {
(true, _, "rotate") => Message::RotateConfirmed,
(true, _, _) => Message::RotateCancelled,
(_, true, "copy") => Message::ReplyConfirmed(true),
(_, true, "without") => Message::ReplyConfirmed(false),
(_, true, _) => Message::ReplyCancelled,
(false, _, "here") => Message::DeleteConfirmed(false),
(false, _, "everywhere") => Message::DeleteConfirmed(true),
(false, _, _) => Message::DeleteCancelled,
});
});
alert.present(Some(&w.window));