mirror of
https://github.com/storytold/lightcraft.git
synced 2026-11-01 05:57:09 -06:00
Issue #2980: Clear Color Label's toast ignores a label parameter
photo.clearLabel takes no colour, but the toast code read params[label] for
it as for photo.label, so photo.clearLabel {label: red} cleared the photo and
showed 'Red Label'. The colour is read for photo.label only.
This commit is contained in:
@@ -252,7 +252,8 @@ impl LightcraftApp {
|
||||
}
|
||||
}
|
||||
if r.is_ok() && matches!(id, "photo.label" | "photo.clearLabel") {
|
||||
let label = params.get("label").and_then(Value::as_str).and_then(lightcraft_catalog::ColorLabel::parse);
|
||||
// Clear Color Label takes no colour: whatever `label` it is given, the photo's label is cleared
|
||||
let label = params.get("label").and_then(Value::as_str).and_then(lightcraft_catalog::ColorLabel::parse).filter(|_| id == "photo.label");
|
||||
let text = match label {
|
||||
Some(label) => {
|
||||
let name =
|
||||
|
||||
@@ -112,6 +112,15 @@ fn compare_clears_only_the_active_photo_and_auto_advance_moves_on() {
|
||||
assert_eq!(app.session.active(), Some(PhotoId(2)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_label_given_to_clear_color_label_is_ignored_by_the_toast_too() {
|
||||
let mut app = app().unwrap();
|
||||
app.run("photo.clearLabel", json!({"label": "red"})).unwrap();
|
||||
assert_eq!(labels(&app)[1], None, "the photo's label is cleared, whatever label was passed");
|
||||
let toast = app.ui.toast.as_ref().expect("a toast");
|
||||
assert_eq!((toast.0.as_str(), toast.2), ("Color label cleared", None), "not \"Red Label\"");
|
||||
}
|
||||
|
||||
fn find<'a>(nodes: &'a [MenuNode], id: &str) -> Option<&'a MenuNode> {
|
||||
nodes.iter().find_map(|n| match n {
|
||||
MenuNode::Item { id: i, .. } if i == id => Some(n),
|
||||
|
||||
Reference in New Issue
Block a user