Lagrange [work/v1.12]

SidebarWidget: Added "Mark Below as Read"

=> 93f4d1ac749c591b33eb657eadddcca8b872f6c7

diff --git a/po/en.po b/po/en.po
index ec7f42a9..aaacbd02 100644
--- a/po/en.po
+++ b/po/en.po
@@ -542,6 +542,9 @@ msgstr "Mark as Read"
 msgid "feeds.entry.markunread"
 msgstr "Mark as Unread"
 
+msgid "feeds.entry.markbelowread"
+msgstr "Mark Below as Read"
+
 msgid "sidebar.entry.bookmark"
 msgstr "Add Bookmark…"
 
diff --git a/src/defs.h b/src/defs.h
index 429601e6..9e967217 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -135,6 +135,7 @@ iLocalDef int acceptKeyMod_ReturnKeyBehavior(int behavior) {
 #define upArrow_Icon        "\U0001f871"
 #define upArrowBar_Icon     "\u2b71"
 #define keyUpArrow_Icon     "\u2191"
+#define downArrow_Icon      "\U0001f873"
 #define downArrowBar_Icon   "\u2913"
 #define rightArrowWhite_Icon "\u21e8"
 #define rightArrow_Icon     "\u279e"
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c
index 2518a63e..652bf764 100644
--- a/src/ui/sidebarwidget.c
+++ b/src/ui/sidebarwidget.c
@@ -261,6 +261,12 @@ static void setMobileEditMode_SidebarWidget_(iSidebarWidget *d, iBool editing) {
     }
 }
 
+static const iPtrArray *listFeedEntries_SidebarWidget_(const iSidebarWidget *d) {
+    iUnused(d);
+    /* TODO: Sort order setting? */
+    return listEntries_Feeds();
+}
+
 static void updateItemsWithFlags_SidebarWidget_(iSidebarWidget *d, iBool keepActions) {
     const iBool isMobile = (deviceType_App() != desktop_AppDeviceType);
     clear_ListWidget(d->list);
@@ -286,7 +292,7 @@ static void updateItemsWithFlags_SidebarWidget_(iSidebarWidget *d, iBool keepAct
             iZap(on);
             size_t numItems = 0;
             isEmpty = iTrue;
-            const iPtrArray *feedEntries = listEntries_Feeds();
+            const iPtrArray *feedEntries = listFeedEntries_SidebarWidget_(d);
             iConstForEach(PtrArray, i, feedEntries) {
                 const iFeedEntry *entry = i.ptr;
                 if (isHidden_FeedEntry(entry)) {
@@ -420,6 +426,7 @@ static void updateItemsWithFlags_SidebarWidget_(iSidebarWidget *d, iBool keepAct
 #endif
                 { "---", 0, 0, NULL },
                 { circle_Icon " ${feeds.entry.markread}", 0, 0, "feed.entry.toggleread" },
+                { downArrow_Icon " ${feeds.entry.markbelowread}", 0, 0, "feed.entry.markread below:1" },
                 { bookmark_Icon " ${feeds.entry.bookmark}", 0, 0, "feed.entry.bookmark" },
                 { "${menu.copyurl}", 0, 0, "feed.entry.copy" },
                 { "---", 0, 0, NULL },
@@ -1649,14 +1656,9 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
                 openMenu_Widget(menu, topLeft_Rect(bounds_Widget(d->actions)));
                 return iTrue;
             }
-            iConstForEach(PtrArray, i, listEntries_Feeds()) {
+            iConstForEach(PtrArray, i, listFeedEntries_SidebarWidget_(d)) {
                 const iFeedEntry *entry = i.ptr;
-                const iString *url = url_FeedEntry(entry);
                 markEntryAsRead_Feeds(entry->bookmarkId, &entry->url, iTrue);
-//                if (!containsUrl_Visited(visited_App(), url)) {
-//                    visitUrl_Visited(visited_App(), url,
-//                                     transient_VisitedUrlFlag | kept_VisitedUrlFlag);
-//                }
             }
             postCommand_App("visited.changed");
             return iTrue;
@@ -1684,6 +1686,24 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
                     postCommand_App("visited.changed");
                     return iTrue;
                 }
+                else if (isCommand_Widget(w, ev, "feed.entry.markread")) {
+                    iBool isBelow = iFalse;
+                    const iBool markingBelow = argLabel_Command(command_UserEvent(ev), "below") != 0;
+                    iConstForEach(PtrArray, i, listFeedEntries_SidebarWidget_(d)) {
+                        const iFeedEntry *entry = i.ptr;
+                        if (isBelow) {
+                            markEntryAsRead_Feeds(entry->bookmarkId, &entry->url, iTrue);
+                        }
+                        else {
+                            if (equal_String(&entry->url, &item->url) &&
+                                entry->bookmarkId == item->id) {
+                                isBelow = iTrue;
+                            }
+                        }
+                    }
+                    postCommand_App("visited.changed");                    
+                    return iTrue;
+                }
                 else if (isCommand_Widget(w, ev, "feed.entry.bookmark")) {
                     makeBookmarkCreation_Widget(&item->url, &item->label, item->icon);
                     if (deviceType_App() == desktop_AppDeviceType) {
@@ -1844,15 +1864,15 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev)
                     }
                 }
                 else if (d->mode == feeds_SidebarMode && d->contextItem) {
-                    const iBool   isRead   = d->contextItem->indent == 0;
+                    const iBool isRead = d->contextItem->indent == 0;
                     setMenuItemLabel_Widget(d->menu,
                                             "feed.entry.toggleread",
                                             isRead ? circle_Icon " ${feeds.entry.markunread}"
                                                    : circleWhite_Icon " ${feeds.entry.markread}");
                 }
-                            }
-                        }
-                    }
+            }
+        }
+    }
     if (ev->type == SDL_KEYDOWN) {
         const int key   = ev->key.keysym.sym;
         const int kmods = keyMods_Sym(ev->key.keysym.mod);
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.12/cdiff/93f4d1ac749c591b33eb657eadddcca8b872f6c7
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
66.350049 milliseconds
Gemini-to-HTML Time
0.295599 milliseconds

This content has been proxied by September (ba2dc).