]> git.wh0rd.org - tt-rss.git/commitdiff
bring back update button, it makes async update request to the daemon
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 13 Nov 2010 15:48:56 +0000 (18:48 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Sat, 13 Nov 2010 15:48:56 +0000 (18:48 +0300)
feedlist.js
functions.php
modules/backend-rpc.php
tt-rss.js
tt-rss.php
viewfeed.js

index b52f134b3fc2dcbea6d539fffa275f9bab8c35e7..9285c61fdc8794e04227a5e4782c2c8c7d160921 100644 (file)
@@ -732,10 +732,12 @@ function parse_counters(reply, scheduled_call) {
 
                        if (updated && feedlink) {
                                if (error) {
-                                       feedlink.title = "Error: " + error + " (" + updated + ")";
+                                       feedlink.title = __("Error:") + " " + error + " (" + updated + ")";
                                } else {
-                                       feedlink.title = "Updated: " + updated;
+                                       feedlink.title = __("Updated:") + " " + updated;
                                }
+                       } else if (!updated && feedlink) {
+                               feedlink.title = __("Updated:") + " " + __("Never");
                        }
 
                        if (feedupd) {
index 7d7e828931b4f5dd0e806eeaf7c07cd45e4c9a9b..553b26563072a7857afcc321559e6e64999aad56 100644 (file)
 
                        $has_img = feed_has_icon($id);
 
+                       if (date('Y') - date('Y', strtotime($line['last_updated'])) > 2)
+                               $last_updated = '';
+
                        $cv = array("id" => $id,
                                "updated" => $last_updated,
                                "counter" => $count,
index a6d495feb23dabc4452dc1a4f988a935d0bbbf76..23706ea3d4b2e3425e6a3b066ebcc68a192133c2 100644 (file)
                        return;
                }
 
+               if ($subop == "scheduleFeedUpdate") {
+                       $feed_id = db_escape_string($_REQUEST["id"]);
+                       $is_cat = db_escape_string($_REQUEST['is_cat']);
+
+                       $message = __("Your request could not be completed.");
+
+                       if ($feed_id >= 0) {
+                               if (!$is_cat) {
+                                       $message = __("Feed update has been scheduled.");
+
+                                       db_query($link, "UPDATE ttrss_feeds SET
+                                               last_update_started = '1970-01-01',
+                                               last_updated = '1970-01-01' WHERE id = '$feed_id' AND
+                                               owner_uid = ".$_SESSION["uid"]);
+
+                               } else {
+                                       $message = __("Category update has been scheduled.");
+
+                                       if ($feed_id) 
+                                               $cat_query = "cat_id = '$feed_id'";
+                                       else
+                                               $cat_query = "cat_id IS NULL";
+
+                                       db_query($link, "UPDATE ttrss_feeds SET
+                                               last_update_started = '1970-01-01',
+                                               last_updated = '1970-01-01' WHERE $cat_query AND
+                                               owner_uid = ".$_SESSION["uid"]);
+                               }
+                       } else {
+                               $message = __("Can't update this kind of feed.");
+                       }
+
+                       print "<rpc-reply>";
+                       print "<message>$message</message>";
+                       print "</rpc-reply>";
+
+                       return;
+               }
+
                print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>
index a3bfbde5d083f8d707cd90b7f3b711b67da4b3b6..35927fd42ace542403fc0f9474f786a549cfa8d1 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -1286,3 +1286,39 @@ function handle_rpc_reply(transport, scheduled_call) {
        return true;
 }
 
+function scheduleFeedUpdate() {
+       try {
+
+               if (!getActiveFeedId()) {
+                       alert(__("Please select some feed first."));
+                       return;
+               }
+
+               var query = "?op=rpc&subop=scheduleFeedUpdate&id=" + 
+                       param_escape(getActiveFeedId()) +
+                       "&is_cat=" + param_escape(activeFeedIsCat());
+
+               console.log(query);
+
+               new Ajax.Request("backend.php", {
+                       parameters: query,
+                       onComplete: function(transport) { 
+
+                               if (transport.responseXML) {
+                                       var message = transport.responseXML.getElementsByTagName("message")[0];
+
+                                       if (message) {
+                                               notify_info(message.firstChild.nodeValue);
+                                               return;
+                                       }
+                               }
+
+                               notify_error("Error communicating with server.");
+
+                       } });
+
+
+       } catch (e) {
+               exception_error("scheduleFeedUpdate", e);
+       }
+}
index a4814b2709fb55cba811c052547f653e967c81a2..869e1338d70c2724bc65a041787385695ad5ec31 100644 (file)
                        <option value="score"><?php echo __('Score') ?></option>
                </select>
 
-               <?php if (defined('_ENABLE_FEED_DEBUGGING')) { ?>
-
-               <button name="update" onclick="return viewCurrentFeed('ForceUpdate')">
+               <button name="update" onclick="return scheduleFeedUpdate()">
                        <?php echo __('Update') ?></button>
 
-               <?php } ?>
-
                <button onclick="return catchupCurrentFeed()">
                        <?php echo __('Mark as read') ?></button>
 
index ebf479243e8f2231ba19f644de3bd59c604dd2a2..fa5c618eed4e42c72a271fa99544a8cca72bafd5 100644 (file)
@@ -58,6 +58,10 @@ function headlines_callback2(transport, feed_cur_page) {
                        }
                }
 
+               var update_btn = document.forms["main_toolbar_form"].update;
+
+               update_btn.disabled = !(feed_id >= 0 && !is_cat);
+
                var ll = $('FLL-' + feed_id);
 
                if (ll && ll.parentNode)