diff options
| author | Joe Carstairs <me@joeac.net> | 2026-02-01 21:12:24 +0000 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-02-01 21:12:45 +0000 |
| commit | 7623882a24e5e72d10109fe549f241bde6a31274 (patch) | |
| tree | 5f31a36f0a01f5b2edbd2b709d2e5cdfee8743b0 | |
| parent | 25453cba38db7ba21543bfaebd48c23006bf1d39 (diff) | |
BucketsView displays groups, not buckets
| -rw-r--r-- | schist_desktop_gui/src/gui/components/buckets_view.rs | 35 |
1 files 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<Bucket>, greeting: &str) -> Self { + pub fn new(groups: Vec<String>, 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<BucketNavigationEntry> = 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) { |
