Skip to content

Commit

Permalink
chore(term): prevent selection out of index
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed May 5, 2024
1 parent d7db514 commit 1cf0160
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/synd_term/src/ui/components/entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ impl Entries {
.filter(|(_idx, entry)| self.filter.entry(entry) == FilterResult::Use)
.map(|(idx, _)| idx)
.collect();
// prevent selection from out of index
self.selected_entry_index = self
.selected_entry_index
.min(self.effective_entries.len().saturating_sub(1));
}

pub fn remove_unsubscribed_entries(&mut self, url: &FeedUrl) {
Expand Down
4 changes: 4 additions & 0 deletions crates/synd_term/src/ui/components/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ impl Subscription {
.filter(|(_idx, feed)| self.filter.feed(feed) == FilterResult::Use)
.map(|(idx, _)| idx)
.collect();
// prevent selection from out of index
self.selected_feed_index = self
.selected_feed_index
.min(self.effective_feeds.len().saturating_sub(1));
}

pub fn upsert_subscribed_feed(&mut self, feed: types::Feed) {
Expand Down

0 comments on commit 1cf0160

Please sign in to comment.