Skip to content

Commit

Permalink
feat(term): show entries count indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
ymgyt committed May 4, 2024
1 parent 206bbad commit fa4abc7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
13 changes: 8 additions & 5 deletions crates/synd_term/src/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,12 @@ impl Application {
} => {
self.in_flight.remove(request_seq);
// paginate
if subscription.feeds.page_info.has_next_page {
next = Some(Command::FetchSubscription {
next = subscription.feeds.page_info.has_next_page.then(|| {
Command::FetchSubscription {
after: subscription.feeds.page_info.end_cursor.clone(),
first: config::client::INITIAL_FEEDS_TO_FETCH,
});
}
first: subscription.feeds.nodes.len().try_into().unwrap_or(0),
}
});
self.components
.subscription
.update_subscription(populate, subscription);
Expand Down Expand Up @@ -599,6 +599,9 @@ impl Application {

impl Application {
fn fetch_subscription(&mut self, populate: Populate, after: Option<String>, first: i64) {
if first <= 0 {
return;
}
let client = self.client.clone();
let request_seq = self.in_flight.add(RequestId::FetchSubscription);
let fut = async move {
Expand Down
14 changes: 13 additions & 1 deletion crates/synd_term/src/ui/components/entries.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::borrow::Cow;

use crate::{
application::{Direction, IndexOutOfRange, Populate},
client::payload,
Expand Down Expand Up @@ -164,9 +166,19 @@ impl Entries {
impl IntoIterator<Item = Constraint>,
impl IntoIterator<Item = Row<'a>>,
) {
let (n, m) = {
if self.effective_entries.is_empty() {
(Cow::Borrowed("-"), Cow::Borrowed("-"))
} else {
(
Cow::Owned((self.selected_entry_index + 1).to_string()),
Cow::Owned(self.effective_entries.len().to_string()),
)
}
};
let header = Row::new([
Cell::from(" Published"),
Cell::from("󰯂 Entry"),
Cell::from(format!("󰯂 Entry {n}/{m}")),
Cell::from("󰑫 Feed"),
Cell::from(concat!(icon!(requirement), " Req")),
]);
Expand Down
12 changes: 11 additions & 1 deletion crates/synd_term/src/ui/components/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,18 @@ impl Subscription {
impl IntoIterator<Item = Constraint>,
impl IntoIterator<Item = Row<'a>>,
) {
let (n, m) = {
if self.effective_feeds.is_empty() {
(Cow::Borrowed("-"), Cow::Borrowed("-"))
} else {
(
Cow::Owned((self.selected_feed_index + 1).to_string()),
Cow::Owned(self.effective_feeds.len().to_string()),
)
}
};
let header = Row::new([
Cell::from("󰑫 Feed"),
Cell::from(format!("󰑫 Feed {n}/{m}")),
Cell::from(" Updated"),
Cell::from(" URL"),
Cell::from("󰎞 Description"),
Expand Down

0 comments on commit fa4abc7

Please sign in to comment.