diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-27 13:38:09 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-27 13:38:09 +0200 |
commit | 701c579186d403aefd49107be00dd38625c6e357 (patch) | |
tree | 262d69db8193a893b04a37c2a6b4f2deae100837 /src/ui/sidebarwidget.c | |
parent | e78b773a4c58c016025fa4e5f5d9ee6f5070fa4d (diff) |
Feeds: Marking all as read; time check improvements
For some unknown reason, the parsing of the entry dates is sometimes (randomly?) off by 3600 seconds (one hour). This need a closer investigation; maybe a DST thing? For now check the date instead.
Diffstat (limited to 'src/ui/sidebarwidget.c')
-rw-r--r-- | src/ui/sidebarwidget.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 2edd28a9..35c19f7c 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -115,12 +115,18 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
115 | switch (d->mode) { | 115 | switch (d->mode) { |
116 | case feeds_SidebarMode: { | 116 | case feeds_SidebarMode: { |
117 | const iString *docUrl = url_DocumentWidget(document_App()); | 117 | const iString *docUrl = url_DocumentWidget(document_App()); |
118 | iTime now; | ||
118 | iDate on; | 119 | iDate on; |
119 | initCurrent_Date(&on); | 120 | initCurrent_Time(&now); |
121 | init_Date(&on, &now); | ||
120 | const int thisYear = on.year; | 122 | const int thisYear = on.year; |
121 | iZap(on); | 123 | iZap(on); |
122 | iConstForEach(PtrArray, i, listEntries_Feeds()) { | 124 | iConstForEach(PtrArray, i, listEntries_Feeds()) { |
123 | const iFeedEntry *entry = i.ptr; | 125 | const iFeedEntry *entry = i.ptr; |
126 | /* Exclude entries that are too old for Visited to keep track of. */ | ||
127 | if (secondsSince_Time(&now, &entry->timestamp) > maxAge_Visited) { | ||
128 | break; /* the rest are even older */ | ||
129 | } | ||
124 | /* Insert date separators. */ { | 130 | /* Insert date separators. */ { |
125 | iDate entryDate; | 131 | iDate entryDate; |
126 | init_Date(&entryDate, &entry->timestamp); | 132 | init_Date(&entryDate, &entry->timestamp); |
@@ -158,13 +164,13 @@ static void updateItems_SidebarWidget_(iSidebarWidget *d) { | |||
158 | as_Widget(d), | 164 | as_Widget(d), |
159 | (iMenuItem[]){ { "Open Entry in New Tab", 0, 0, "feed.entry.opentab" }, | 165 | (iMenuItem[]){ { "Open Entry in New Tab", 0, 0, "feed.entry.opentab" }, |
160 | { "Open Feed Page", 0, 0, "feed.entry.openfeed" }, | 166 | { "Open Feed Page", 0, 0, "feed.entry.openfeed" }, |
161 | { "---", 0, 0, NULL }, | ||
162 | { "Mark as Read", 0, 0, "feed.entry.toggleread" }, | 167 | { "Mark as Read", 0, 0, "feed.entry.toggleread" }, |
163 | { "Add Bookmark...", 0, 0, "feed.entry.bookmark" }, | 168 | { "Add Bookmark...", 0, 0, "feed.entry.bookmark" }, |
164 | { "Edit Feed...", 0, 0, "feed.entry.edit" }, | ||
165 | { "---", 0, 0, NULL }, | 169 | { "---", 0, 0, NULL }, |
170 | { "Edit Feed...", 0, 0, "feed.entry.edit" }, | ||
166 | { uiTextCaution_ColorEscape "Unsubscribe...", 0, 0, "feed.entry.unsubscribe" }, | 171 | { uiTextCaution_ColorEscape "Unsubscribe...", 0, 0, "feed.entry.unsubscribe" }, |
167 | { "---", 0, 0, NULL }, | 172 | { "---", 0, 0, NULL }, |
173 | { "Mark All as Read", SDLK_a, KMOD_SHIFT, "feeds.markallread" }, | ||
168 | { "Refresh Feeds", SDLK_r, KMOD_PRIMARY | KMOD_SHIFT, "feeds.refresh" } }, | 174 | { "Refresh Feeds", SDLK_r, KMOD_PRIMARY | KMOD_SHIFT, "feeds.refresh" } }, |
169 | 10); | 175 | 10); |
170 | break; | 176 | break; |
@@ -694,6 +700,17 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
694 | else if (equal_Command(cmd, "feeds.update.finished") && d->mode == feeds_SidebarMode) { | 700 | else if (equal_Command(cmd, "feeds.update.finished") && d->mode == feeds_SidebarMode) { |
695 | updateItems_SidebarWidget_(d); | 701 | updateItems_SidebarWidget_(d); |
696 | } | 702 | } |
703 | else if (equal_Command(cmd, "feeds.markallread") && d->mode == feeds_SidebarMode) { | ||
704 | iConstForEach(PtrArray, i, listEntries_Feeds()) { | ||
705 | const iFeedEntry *entry = i.ptr; | ||
706 | const iString *url = &entry->url; | ||
707 | if (!containsUrl_Visited(visited_App(), url)) { | ||
708 | visitUrl_Visited(visited_App(), url, transient_VisitedUrlFlag); | ||
709 | } | ||
710 | } | ||
711 | postCommand_App("visited.changed"); | ||
712 | return iTrue; | ||
713 | } | ||
697 | else if (startsWith_CStr(cmd, "feed.entry.") && d->mode == feeds_SidebarMode) { | 714 | else if (startsWith_CStr(cmd, "feed.entry.") && d->mode == feeds_SidebarMode) { |
698 | const iSidebarItem *item = d->contextItem; | 715 | const iSidebarItem *item = d->contextItem; |
699 | if (item) { | 716 | if (item) { |