summaryrefslogtreecommitdiff
path: root/src/feeds.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-26 14:32:27 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-26 14:32:27 +0200
commitf895842fbb9d7ddf95bf721f05af3e561ed1c81c (patch)
treec1de6ab775f50d1018895257767ba969b6a75977 /src/feeds.c
parent7f02b8d0c2234f36294fd14a01dc16bb6f6a1cca (diff)
Feeds: "about:feeds" shows refresh time
Diffstat (limited to 'src/feeds.c')
-rw-r--r--src/feeds.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/feeds.c b/src/feeds.c
index a1b7414e..9538d948 100644
--- a/src/feeds.c
+++ b/src/feeds.c
@@ -465,17 +465,27 @@ const iPtrArray *listEntries_Feeds(void) {
465 return list; 465 return list;
466} 466}
467 467
468#define iPluralS(c) ((c) != 1 ? "s" : "")
469
468const iString *entryListPage_Feeds(void) { 470const iString *entryListPage_Feeds(void) {
469 iFeeds *d = &feeds_; 471 iFeeds *d = &feeds_;
470 iString *src = collectNew_String(); 472 iString *src = collectNew_String();
471 format_String(src, "# Aggregated Gemini feeds\n"); 473 format_String(src, "# Aggregated Gemini feeds\n");
472 lock_Mutex(d->mtx); 474 lock_Mutex(d->mtx);
473 const iPtrArray *subs = listSubscriptions_(); 475 const iPtrArray *subs = listSubscriptions_();
474 appendFormat_String(src, "You are subscribed to %zu feed%s that contain%s a total of %zu entries.\n", 476 int elapsed = elapsedSeconds_Time(&d->lastRefreshedAt) / 60;
475 size_PtrArray(subs), 477 appendFormat_String(
476 size_PtrArray(subs) != 1 ? "s" : "", 478 src,
477 size_PtrArray(subs) == 1 ? "s" : "", 479 "You are subscribed to %zu feed%s that contain%s a total of %zu entries.\n\n"
478 size_SortedArray(&d->entries)); 480 "The latest refresh occurred %s.\n",
481 size_PtrArray(subs),
482 iPluralS(size_PtrArray(subs)),
483 size_PtrArray(subs) == 1 ? "s" : "",
484 size_SortedArray(&d->entries),
485 elapsed == 0 ? "just a moment ago"
486 : elapsed < 60 ? format_CStr("%d minute%s ago", elapsed, iPluralS(elapsed))
487 : elapsed < 1440 ? format_CStr("%d hour%s ago", elapsed / 60, iPluralS(elapsed / 60))
488 : format_CStr("%d day%s ago", elapsed / 1440, iPluralS(elapsed / 1440)));
479 iDate on; 489 iDate on;
480 iZap(on); 490 iZap(on);
481 iConstForEach(PtrArray, i, listEntries_Feeds()) { 491 iConstForEach(PtrArray, i, listEntries_Feeds()) {