diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-18 19:22:03 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-01-18 19:22:03 +0200 |
commit | e8412f167ec2c8d72055181c2c5e1df09699a94e (patch) | |
tree | 17d8abb099580ac109f1ab16dab1f5c4c02998e8 /src | |
parent | e39a4035a622e1e9e1573cc567cb43652fdef231 (diff) |
Fixed opening heading feed entries in a tab
The heading goto fragment wasn't being stripped appropriately from the URLs.
Diffstat (limited to 'src')
-rw-r--r-- | src/feeds.c | 8 | ||||
-rw-r--r-- | src/gmutil.c | 9 | ||||
-rw-r--r-- | src/gmutil.h | 1 | ||||
-rw-r--r-- | src/ui/sidebarwidget.c | 11 |
4 files changed, 18 insertions, 11 deletions
diff --git a/src/feeds.c b/src/feeds.c index 75173ee1..a40df571 100644 --- a/src/feeds.c +++ b/src/feeds.c | |||
@@ -57,12 +57,7 @@ void deinit_FeedEntry(iFeedEntry *d) { | |||
57 | } | 57 | } |
58 | 58 | ||
59 | const iString *url_FeedEntry(const iFeedEntry *d) { | 59 | const iString *url_FeedEntry(const iFeedEntry *d) { |
60 | const size_t fragPos = indexOf_String(&d->url, '#'); | 60 | return urlFragmentStripped_String(&d->url); |
61 | if (fragPos != iInvalidPos) { | ||
62 | return collect_String(newRange_String((iRangecc){ constBegin_String(&d->url), | ||
63 | constBegin_String(&d->url) + fragPos })); | ||
64 | } | ||
65 | return &d->url; | ||
66 | } | 61 | } |
67 | 62 | ||
68 | iBool isUnread_FeedEntry(const iFeedEntry *d) { | 63 | iBool isUnread_FeedEntry(const iFeedEntry *d) { |
@@ -300,6 +295,7 @@ static iBool updateEntries_Feeds_(iFeeds *d, iPtrArray *incoming) { | |||
300 | size_t pos; | 295 | size_t pos; |
301 | if (locate_SortedArray(&d->entries, &entry, &pos)) { | 296 | if (locate_SortedArray(&d->entries, &entry, &pos)) { |
302 | iFeedEntry *existing = *(iFeedEntry **) at_SortedArray(&d->entries, pos); | 297 | iFeedEntry *existing = *(iFeedEntry **) at_SortedArray(&d->entries, pos); |
298 | iAssert(isHeadingEntry_FeedEntry_(existing) == isHeadingEntry_FeedEntry_(entry)); | ||
303 | /* Already known, but update it, maybe the time and label have changed. */ | 299 | /* Already known, but update it, maybe the time and label have changed. */ |
304 | if (!isHeadingEntry_FeedEntry_(existing)) { | 300 | if (!isHeadingEntry_FeedEntry_(existing)) { |
305 | iBool changed = iFalse; | 301 | iBool changed = iFalse; |
diff --git a/src/gmutil.c b/src/gmutil.c index 69fa6d9f..0f1bc803 100644 --- a/src/gmutil.c +++ b/src/gmutil.c | |||
@@ -91,6 +91,15 @@ void stripDefaultUrlPort_String(iString *d) { | |||
91 | } | 91 | } |
92 | } | 92 | } |
93 | 93 | ||
94 | const iString *urlFragmentStripped_String(const iString *d) { | ||
95 | const size_t fragPos = indexOf_String(d, '#'); | ||
96 | if (fragPos != iInvalidPos) { | ||
97 | return collect_String(newRange_String((iRangecc){ constBegin_String(d), | ||
98 | constBegin_String(d) + fragPos })); | ||
99 | } | ||
100 | return d; | ||
101 | } | ||
102 | |||
94 | void cleanUrlPath_String(iString *d) { | 103 | void cleanUrlPath_String(iString *d) { |
95 | iString clean; | 104 | iString clean; |
96 | init_String(&clean); | 105 | init_String(&clean); |
diff --git a/src/gmutil.h b/src/gmutil.h index 7227a072..3fd1268d 100644 --- a/src/gmutil.h +++ b/src/gmutil.h | |||
@@ -105,6 +105,7 @@ iRangecc urlHost_String (const iString *); | |||
105 | const iString * absoluteUrl_String (const iString *, const iString *urlMaybeRelative); | 105 | const iString * absoluteUrl_String (const iString *, const iString *urlMaybeRelative); |
106 | void punyEncodeUrlHost_String(iString *); | 106 | void punyEncodeUrlHost_String(iString *); |
107 | void stripDefaultUrlPort_String(iString *); | 107 | void stripDefaultUrlPort_String(iString *); |
108 | const iString * urlFragmentStripped_String(const iString *); | ||
108 | void urlDecodePath_String (iString *); | 109 | void urlDecodePath_String (iString *); |
109 | void urlEncodePath_String (iString *); | 110 | void urlEncodePath_String (iString *); |
110 | iString * makeFileUrl_String (const iString *localFilePath); | 111 | iString * makeFileUrl_String (const iString *localFilePath); |
diff --git a/src/ui/sidebarwidget.c b/src/ui/sidebarwidget.c index 56b8d097..32dcf61f 100644 --- a/src/ui/sidebarwidget.c +++ b/src/ui/sidebarwidget.c | |||
@@ -822,7 +822,7 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
822 | else if (equal_Command(cmd, "feeds.markallread") && d->mode == feeds_SidebarMode) { | 822 | else if (equal_Command(cmd, "feeds.markallread") && d->mode == feeds_SidebarMode) { |
823 | iConstForEach(PtrArray, i, listEntries_Feeds()) { | 823 | iConstForEach(PtrArray, i, listEntries_Feeds()) { |
824 | const iFeedEntry *entry = i.ptr; | 824 | const iFeedEntry *entry = i.ptr; |
825 | const iString *url = &entry->url; | 825 | const iString *url = url_FeedEntry(entry); |
826 | if (!containsUrl_Visited(visited_App(), url)) { | 826 | if (!containsUrl_Visited(visited_App(), url)) { |
827 | visitUrl_Visited(visited_App(), url, transient_VisitedUrlFlag); | 827 | visitUrl_Visited(visited_App(), url, transient_VisitedUrlFlag); |
828 | } | 828 | } |
@@ -834,16 +834,17 @@ static iBool processEvent_SidebarWidget_(iSidebarWidget *d, const SDL_Event *ev) | |||
834 | const iSidebarItem *item = d->contextItem; | 834 | const iSidebarItem *item = d->contextItem; |
835 | if (item) { | 835 | if (item) { |
836 | if (isCommand_Widget(w, ev, "feed.entry.opentab")) { | 836 | if (isCommand_Widget(w, ev, "feed.entry.opentab")) { |
837 | postCommandf_App("open newtab:1 url:%s", cstr_String(&item->url)); | 837 | postCommandString_App(feedEntryOpenCommand_String(&item->url, 1)); |
838 | return iTrue; | 838 | return iTrue; |
839 | } | 839 | } |
840 | if (isCommand_Widget(w, ev, "feed.entry.toggleread")) { | 840 | if (isCommand_Widget(w, ev, "feed.entry.toggleread")) { |
841 | iVisited *vis = visited_App(); | 841 | iVisited *vis = visited_App(); |
842 | if (containsUrl_Visited(vis, &item->url)) { | 842 | const iString *url = urlFragmentStripped_String(&item->url); |
843 | removeUrl_Visited(vis, &item->url); | 843 | if (containsUrl_Visited(vis, url)) { |
844 | removeUrl_Visited(vis, url); | ||
844 | } | 845 | } |
845 | else { | 846 | else { |
846 | visitUrl_Visited(vis, &item->url, transient_VisitedUrlFlag); | 847 | visitUrl_Visited(vis, url, transient_VisitedUrlFlag); |
847 | } | 848 | } |
848 | postCommand_App("visited.changed"); | 849 | postCommand_App("visited.changed"); |
849 | return iTrue; | 850 | return iTrue; |