From 7623882a24e5e72d10109fe549f241bde6a31274 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sun, 1 Feb 2026 21:12:24 +0000 Subject: BucketsView displays groups, not buckets --- .../src/gui/components/buckets_view.rs | 35 +++++++++++++++------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/schist_desktop_gui/src/gui/components/buckets_view.rs b/schist_desktop_gui/src/gui/components/buckets_view.rs index 7419b7d..b908fb3 100644 --- a/schist_desktop_gui/src/gui/components/buckets_view.rs +++ b/schist_desktop_gui/src/gui/components/buckets_view.rs @@ -30,14 +30,18 @@ pub enum Action { } impl BucketsView { - pub fn new(buckets: Vec, greeting: &str) -> Self { + pub fn new(groups: Vec, greeting: &str) -> Self { Self { greeting: greeting.to_owned(), navigation: Navigation::new( - buckets.first().map(BucketNavigationEntry::from_bucket), - buckets + groups + .first() + .map(String::as_str) + .map(BucketNavigationEntry::from_group_closed), + groups .iter() - .map(BucketNavigationEntry::from_bucket) + .map(String::as_str) + .map(BucketNavigationEntry::from_group_closed) .collect(), ), } @@ -77,13 +81,22 @@ impl<'a> Component<'a, Message, Action> for BucketsView { fn update(&mut self, message: Message) -> Action { match message { Message::SetBuckets(buckets) => { - self.navigation.update(navigation::Message::SetOptions( - buckets - .iter() - .map(BucketNavigationEntry::from_bucket) - .collect(), - )); - Action::None + let groups: Vec = buckets + .iter() + .map(|bucket| bucket.group.as_str()) + .unique() + .map(BucketNavigationEntry::from_group_closed) + .collect(); + match self + .navigation + .update(navigation::Message::SetOptions(groups)) + { + navigation::Action::SelectOption(bucket_navigation_entry) => { + self.update_greeting(&bucket_navigation_entry.to_string()); + Action::None + } + navigation::Action::None => Action::None, + } } Message::NavigationMessage(message) => match self.navigation.update(message) { -- cgit v1.2.3