diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-27 18:12:35 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-11-27 18:12:35 +0200 |
commit | fb3d35b60463d3e96dca2712eb26e99d85ea1968 (patch) | |
tree | 4b1d31c345c49e9c3fac752b1c229958e8cae2a9 /src | |
parent | a7a069ddaa827ad373b4b283e979a23e931f9433 (diff) |
Autoupdate feeds after subscribing to the first one
Diffstat (limited to 'src')
-rw-r--r-- | src/app.c | 14 | ||||
-rw-r--r-- | src/feeds.c | 4 | ||||
-rw-r--r-- | src/feeds.h | 1 |
3 files changed, 14 insertions, 5 deletions
@@ -1243,18 +1243,22 @@ iBool handleCommand_App(const char *cmd) { | |||
1243 | return iTrue; | 1243 | return iTrue; |
1244 | } | 1244 | } |
1245 | else if (equal_Command(cmd, "bookmark.addtag")) { | 1245 | else if (equal_Command(cmd, "bookmark.addtag")) { |
1246 | const iString *tag = string_Command(cmd, "tag"); | 1246 | const iString *tag = string_Command(cmd, "tag"); |
1247 | const iString *feedUrl = url_DocumentWidget(document_App()); | 1247 | const iString *url = url_DocumentWidget(document_App()); |
1248 | if (!isEmpty_String(feedUrl)) { | 1248 | const size_t numSubs = numSubscribed_Feeds(); |
1249 | uint32_t id = findUrl_Bookmarks(d->bookmarks, feedUrl); | 1249 | if (!isEmpty_String(url)) { |
1250 | uint32_t id = findUrl_Bookmarks(d->bookmarks, url); | ||
1250 | if (id) { | 1251 | if (id) { |
1251 | addTag_Bookmark(get_Bookmarks(d->bookmarks, id), cstr_String(tag)); | 1252 | addTag_Bookmark(get_Bookmarks(d->bookmarks, id), cstr_String(tag)); |
1252 | } | 1253 | } |
1253 | else { | 1254 | else { |
1254 | add_Bookmarks(d->bookmarks, feedUrl, bookmarkTitle_DocumentWidget(document_App()), | 1255 | add_Bookmarks(d->bookmarks, url, bookmarkTitle_DocumentWidget(document_App()), |
1255 | tag, siteIcon_GmDocument(document_DocumentWidget(document_App()))); | 1256 | tag, siteIcon_GmDocument(document_DocumentWidget(document_App()))); |
1256 | } | 1257 | } |
1257 | postCommand_App("bookmarks.changed"); | 1258 | postCommand_App("bookmarks.changed"); |
1259 | if (numSubs == 0 && !cmp_String(tag, "subscribed")) { | ||
1260 | postCommand_App("feeds.refresh"); | ||
1261 | } | ||
1258 | } | 1262 | } |
1259 | return iTrue; | 1263 | return iTrue; |
1260 | } | 1264 | } |
diff --git a/src/feeds.c b/src/feeds.c index 9fe6314c..47adb150 100644 --- a/src/feeds.c +++ b/src/feeds.c | |||
@@ -504,6 +504,10 @@ const iPtrArray *listEntries_Feeds(void) { | |||
504 | return list; | 504 | return list; |
505 | } | 505 | } |
506 | 506 | ||
507 | size_t numSubscribed_Feeds(void) { | ||
508 | return size_PtrArray(listSubscriptions_()); | ||
509 | } | ||
510 | |||
507 | #define iPluralS(c) ((c) != 1 ? "s" : "") | 511 | #define iPluralS(c) ((c) != 1 ? "s" : "") |
508 | 512 | ||
509 | const iString *entryListPage_Feeds(void) { | 513 | const iString *entryListPage_Feeds(void) { |
diff --git a/src/feeds.h b/src/feeds.h index caa2a6ef..85769ba8 100644 --- a/src/feeds.h +++ b/src/feeds.h | |||
@@ -44,3 +44,4 @@ void refreshFinished_Feeds (void); /* called on "feeds.update.finished" */ | |||
44 | 44 | ||
45 | const iPtrArray * listEntries_Feeds (void); | 45 | const iPtrArray * listEntries_Feeds (void); |
46 | const iString * entryListPage_Feeds (void); | 46 | const iString * entryListPage_Feeds (void); |
47 | size_t numSubscribed_Feeds (void); | ||