summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2020-11-27 18:12:35 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2020-11-27 18:12:35 +0200
commitfb3d35b60463d3e96dca2712eb26e99d85ea1968 (patch)
tree4b1d31c345c49e9c3fac752b1c229958e8cae2a9
parenta7a069ddaa827ad373b4b283e979a23e931f9433 (diff)
Autoupdate feeds after subscribing to the first one
-rw-r--r--src/app.c14
-rw-r--r--src/feeds.c4
-rw-r--r--src/feeds.h1
3 files changed, 14 insertions, 5 deletions
diff --git a/src/app.c b/src/app.c
index 99e42fc2..57fa3318 100644
--- a/src/app.c
+++ b/src/app.c
@@ -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
507size_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
509const iString *entryListPage_Feeds(void) { 513const 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
45const iPtrArray * listEntries_Feeds (void); 45const iPtrArray * listEntries_Feeds (void);
46const iString * entryListPage_Feeds (void); 46const iString * entryListPage_Feeds (void);
47size_t numSubscribed_Feeds (void);