]> git.wh0rd.org Git - tt-rss.git/commitdiff
force refetch feed when clicking update/clicking on same feed in the tree
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 25 Oct 2012 09:15:14 +0000 (13:15 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 25 Oct 2012 09:15:14 +0000 (13:15 +0400)
classes/feeds.php
include/rssfuncs.php
index.php
js/FeedTree.js
js/feedlist.js
js/tt-rss.js

index 836bbb060ce604e7f37414e66b6400bd6fb514d9..df206c2efadbbe20118cf0fc51932cb69536ec10 100644 (file)
@@ -134,9 +134,20 @@ class Feeds extends Handler_Protected {
 \r
                $method_split = explode(":", $method);\r
 \r
-               if ($method == "ForceUpdate" && $feed && is_numeric($feed) > 0) {\r
-                       include "rssfuncs.php";\r
-                       update_rss_feed($this->link, $feed, true);\r
+               if ($method == "ForceUpdate" && $feed > 0 && is_numeric($feed)) {\r
+                       // Update the feed if required with some basic flood control\r
+\r
+                       $result = db_query($this->link,\r
+                               "SELECT ".SUBSTRING_FOR_DATE."(last_updated,1,19) AS last_updated\r
+                                       FROM ttrss_feeds WHERE id = '$feed'");\r
+\r
+                               if (db_num_rows($result) != 0) {\r
+                                       $last_updated = strtotime(db_fetch_result($result, 0, "last_updated"));\r
+                                       if (time() - $last_updated > 120) {\r
+                                               include "rssfuncs.php";\r
+                                               update_rss_feed($this->link, $feed, true, true);\r
+                                       }\r
+                               }\r
                }\r
 \r
                if ($method_split[0] == "MarkAllReadGR")  {\r
index 09fd457b6079daa4ce8efa01cb12baf73a2dcd97..14fa5f34838640c5de79e435fadd53f923eb3987 100644 (file)
 
                        define('MAGPIE_CACHE_AGE', $cache_age);
                        define('MAGPIE_CACHE_ON', !$no_cache);
-                       define('MAGPIE_FETCH_TIME_OUT', 60);
+                       define('MAGPIE_FETCH_TIME_OUT', $no_cache ? 15 : 60);
                        define('MAGPIE_CACHE_DIR', CACHE_DIR . "/magpie");
 
                        $rss = @fetch_rss($fetch_url);
 
                        $rss = new SimplePie();
                        $rss->set_useragent(SELF_USER_AGENT);
-#                      $rss->set_timeout(10);
+                       $rss->set_timeout($no_cache ? 15 : 60);
                        $rss->set_feed_url($fetch_url);
                        $rss->set_output_encoding('UTF-8');
                        //$rss->force_feed(true);
index 4c4fa5415e7377fb41a73385a9d699f76b686f9e..09c4dc8c7c83ae3e74e69c599f10a48fc38b257a 100644 (file)
--- a/index.php
+++ b/index.php
                </select>
 
                <button dojoType="dijit.form.Button" name="update"
-                       onclick="scheduleFeedUpdate()">
+                       onclick="viewCurrentFeed()">
                        <?php echo __('Update') ?></button>
 
                <button dojoType="dijit.form.Button"
index a197935be164c0f193cc6a22317665fc5927f9fa..bff9b8c88b4fb338b789467bd20363eeb1fcb222 100644 (file)
@@ -137,11 +137,11 @@ dojo.declare("fox.FeedTree", dijit.Tree, {
                                                editFeed(this.getParent().row_id, false);
                                        }}));
 
-                               menu.addChild(new dijit.MenuItem({
+                               /* menu.addChild(new dijit.MenuItem({
                                        label: __("Update feed"),
                                        onClick: function() {
-                                               scheduleFeedUpdate(this.getParent().row_id, false);
-                                       }}));
+                                               heduleFeedUpdate(this.getParent().row_id, false);
+                                       }})); */
                        }
 
                        menu.bindDomNode(tnode.domNode);
index b7cd57c5c2109914f4272d6afaf37d0c2f9edd54..5587c0f3025fb85233b6ea18d22fd6bd3cdeb73b 100644 (file)
@@ -149,7 +149,11 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) {
                var toolbar_query = Form.serialize("main_toolbar_form");
 
                var query = "?op=feeds&method=view&feed=" + feed + "&" +
-                       toolbar_query + "&m=" + param_escape(method);
+                       toolbar_query;
+
+               if (method) {
+                       query = query + "&m=" + param_escape(method);
+               }
 
                if (!background) {
                        if (_search_query) {
@@ -165,6 +169,10 @@ function viewfeed(feed, method, is_cat, offset, background, infscroll_req) {
                                if (vgroup_last_feed) {
                                        query = query + "&vgrlf=" + param_escape(vgroup_last_feed);
                                }
+                       } else {
+                               if (!method && !is_cat && feed == getActiveFeedId()) {
+                                       query = query + "&m=ForceUpdate";
+                               }
                        }
 
                        Form.enable("main_toolbar_form");
index 4c53d9e1768112dc712fba283bd006a619a45028..f83ba377780ea7bb3f1d11c8b57b58e8d37c8498 100644 (file)
@@ -1040,45 +1040,6 @@ function reverseHeadlineOrder() {
        }
 }
 
-function scheduleFeedUpdate(id, is_cat) {
-       try {
-               if (!id) {
-                       id = getActiveFeedId();
-                       is_cat = activeFeedIsCat();
-               }
-
-               if (!id) {
-                       alert(__("Please select some feed first."));
-                       return;
-               }
-
-               var query = "?op=rpc&method=scheduleFeedUpdate&id=" +
-                       param_escape(id) +
-                       "&is_cat=" + param_escape(is_cat);
-
-               console.log(query);
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) {
-                               handle_rpc_json(transport);
-
-                               var reply = JSON.parse(transport.responseText);
-                               var message = reply['message'];
-
-                               if (message) {
-                                       notify_info(message);
-                                       return;
-                               }
-
-                       } });
-
-
-       } catch (e) {
-               exception_error("scheduleFeedUpdate", e);
-       }
-}
-
 function newVersionDlg() {
        try {
                var query = "backend.php?op=dlg&method=newVersion";