summaryrefslogtreecommitdiff
path: root/src/feeds.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-03-20 21:37:53 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-03-20 21:37:53 +0200
commitf29d675303203309dcb4b772f8cc81068c0f97c0 (patch)
treef280a60c2054cbcca64a3074a9402b59108764f4 /src/feeds.c
parent5dfb890cf841579edaeb2633025db218e86f45c2 (diff)
Show unread entry count in sidebar
Diffstat (limited to 'src/feeds.c')
-rw-r--r--src/feeds.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/feeds.c b/src/feeds.c
index 73c68987..db426994 100644
--- a/src/feeds.c
+++ b/src/feeds.c
@@ -381,7 +381,8 @@ static iThreadResult fetch_Feeds_(iThread *thread) {
381 } 381 }
382 initCurrent_Time(&d->lastRefreshedAt); 382 initCurrent_Time(&d->lastRefreshedAt);
383 save_Feeds_(d); 383 save_Feeds_(d);
384 postCommandf_App("feeds.update.finished arg:%d", gotNew ? 1 : 0); 384 postCommandf_App("feeds.update.finished arg:%d unread:%zu", gotNew ? 1 : 0,
385 numUnread_Feeds());
385 return 0; 386 return 0;
386} 387}
387 388
@@ -624,6 +625,18 @@ size_t numSubscribed_Feeds(void) {
624 return size_PtrArray(listSubscriptions_()); 625 return size_PtrArray(listSubscriptions_());
625} 626}
626 627
628size_t numUnread_Feeds(void) {
629 size_t count = 0;
630 size_t max = 100; /* match the number of items shown in the sidebar */
631 iConstForEach(PtrArray, i, listEntries_Feeds()) {
632 if (!max--) break;
633 if (isUnread_FeedEntry(i.ptr)) {
634 count++;
635 }
636 }
637 return count;
638}
639
627#define iPluralS(c) ((c) != 1 ? "s" : "") 640#define iPluralS(c) ((c) != 1 ? "s" : "")
628 641
629const iString *entryListPage_Feeds(void) { 642const iString *entryListPage_Feeds(void) {