diff --git a/ui/dr-ui/src/library_ui.rs b/ui/dr-ui/src/library_ui.rs index 819a1df..bb85245 100644 --- a/ui/dr-ui/src/library_ui.rs +++ b/ui/dr-ui/src/library_ui.rs @@ -4640,26 +4640,41 @@ pub fn wire( let ctl = ctl.clone(); window.on_library_toggle_date_range(move || { let Some(w) = weak.upgrade() else { return }; - let on = !ctl.filter.borrow().has_date_range(); + // Whether the *controls* are showing, which is not the same as + // whether a range is set — and reading it from the filter was why + // pressing this did nothing. The fields are how a range gets set, + // so requiring one before they appear is a door locked from the + // inside. + let on = !w.get_library_range_active(); if on { - // The span the axis is currently drawn over, which is what the - // user is looking at when they ask for "this range". - let borrow = ctl.catalog.borrow(); - let Some(catalog) = borrow.as_ref() else { - return; + // Seeded from the span the axis is drawn over, which is what + // the user is looking at when they ask for "this range". + // + // Only a seed. If there is no catalog yet, or nothing in it + // carries a capture date — dates are read from EXIF as + // thumbnails load, so a freshly opened library has none — the + // fields simply open empty and wait to be typed into. This + // used to `return` in both cases, which meant the button + // silently did nothing on exactly the libraries where a person + // is most likely to be looking for a date. + let seeded = { + let borrow = ctl.catalog.borrow(); + borrow + .as_ref() + .and_then(|catalog| catalog_span(catalog, &ctl)) + .map(|span| { + zoomed_span( + span, + *ctl.timeline_zoom.borrow(), + *ctl.timeline_centre.borrow(), + ) + }) }; - let Some(span) = catalog_span(catalog, &ctl) else { - return; - }; - let (from, to) = zoomed_span( - span, - *ctl.timeline_zoom.borrow(), - *ctl.timeline_centre.borrow(), - ); - drop(borrow); - let mut f = ctl.filter.borrow_mut(); - f.captured_from = Some(from); - f.captured_to = Some(to); + if let Some((from, to)) = seeded { + let mut f = ctl.filter.borrow_mut(); + f.captured_from = Some(from); + f.captured_to = Some(to); + } } else { let mut f = ctl.filter.borrow_mut(); f.captured_from = None;