From 11a63fc7a8cde610f9f152993b40f8652ebe802a Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sat, 22 Aug 2026 22:10:40 +0200 Subject: [PATCH] Refresh the collection tree when a sync brings membership MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New-York gained 127 photographs from the tablet and the sidebar went on showing no number beside it. Two reasons, and the second is why the first was never noticed. The sync's completion handler reloads the grid and never rebuilds the tree — the scan already does, and the sync merges the same tables. And the condition it reloads under was `collections_gained > 0`, which counts collections, not members: a sync that files 127 photographs into a collection both devices already had gains no collection at all, so the count was zero and nothing refreshed. `SyncReport` now carries `members_gained` from the merge report, and either one rebuilds the tree. Co-Authored-By: Claude Opus 5 (1M context) --- ui/dr-ui/src/derived_sync.rs | 8 ++++++++ ui/dr-ui/src/library_ui.rs | 25 ++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/ui/dr-ui/src/derived_sync.rs b/ui/dr-ui/src/derived_sync.rs index 165b589..12de793 100644 --- a/ui/dr-ui/src/derived_sync.rs +++ b/ui/dr-ui/src/derived_sync.rs @@ -53,6 +53,13 @@ pub struct SyncReport { pub catalog_uploaded: bool, pub catalog_merged: bool, pub collections_gained: usize, + /// Membership rows the merge brought in (FR-CAT-7). + /// + /// Counted apart from `collections_gained`, which counts the collections + /// themselves. A sync that files 127 photographs into a collection both + /// devices already had gains *no* collection, and reporting only the + /// former left the sidebar showing no count beside a full collection. + pub members_gained: usize, } impl SyncReport { @@ -334,6 +341,7 @@ async fn sync_catalog( Ok(merge) => { report.catalog_merged = true; report.collections_gained = merge.inserted + merge.updated; + report.members_gained = merge.members_added; } Err(e) => log::warn!("merging remote catalog: {e}"), }, diff --git a/ui/dr-ui/src/library_ui.rs b/ui/dr-ui/src/library_ui.rs index 06405dc..0e5fc37 100644 --- a/ui/dr-ui/src/library_ui.rs +++ b/ui/dr-ui/src/library_ui.rs @@ -3211,9 +3211,32 @@ fn start_derived_sync(window: &AppWindow, ctl: &Rc) { } // Adopted thumbnails and merged collections both change // what the grid should show. - if report.thumbnails_adopted > 0 || report.collections_gained > 0 { + if report.thumbnails_adopted > 0 + || report.collections_gained > 0 + || report.members_gained > 0 + { load_window(&w, &ctl_cb); } + // TRACES: FR-CAT-7 + // And the sidebar, which the grid reload does not + // touch. Membership counts as a change: a sync that + // files 127 photographs into a collection both devices + // already had gains no *collection*, so keying this on + // `collections_gained` alone left the tree showing no + // number beside a collection that had just been filled. + // + // The scan already does this after it finishes; the + // sync merges the same tables and did not. + if report.collections_gained > 0 || report.members_gained > 0 { + let coll = ctl_cb.coll_ctl.borrow().as_ref().and_then(|w| w.upgrade()); + if let Some(coll) = coll { + let borrow = ctl_cb.catalog(); + let borrow = borrow.borrow(); + if let Some(cat) = borrow.as_ref() { + crate::collections_ui::refresh_tree(&w, &coll, cat); + } + } + } stop(&ctl_cb.sync_timer); return; }