summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2015-08-12 16:19:42 +0300
committerAndrew Dolgov <[email protected]>2015-08-12 16:19:42 +0300
commitf9c1f8b0d4e83d2984bcc0d60a0a0b3635459807 (patch)
tree3a65d7bd125d1646497f1db1d2e98e6d83f0109a
parent1edff0d439202fdf5fab831f91dc7b3e9ce839e1 (diff)
pref-feeds: check for inactive feeds asynchronously
-rw-r--r--classes/pref/feeds.php46
-rw-r--r--js/prefs.js14
2 files changed, 36 insertions, 24 deletions
diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php
index 4194eda98..98eadf39c 100644
--- a/classes/pref/feeds.php
+++ b/classes/pref/feeds.php
@@ -1298,30 +1298,11 @@ class Pref_Feeds extends Handler_Protected {
__("Feeds with errors") . "</button>";
}
- if (DB_TYPE == "pgsql") {
- $interval_qpart = "NOW() - INTERVAL '3 months'";
- } else {
- $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
- }
-
- // could be performance-intensive and prevent feeds pref-panel from showing
- if (!defined('_DISABLE_INACTIVE_FEEDS') || !_DISABLE_INACTIVE_FEEDS) {
- $result = $this->dbh->query("SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
- (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
- ttrss_entries.id = ref_id AND
- ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
- ttrss_feeds.owner_uid = ".$_SESSION["uid"]);
-
- $num_inactive = $this->dbh->fetch_result($result, 0, "num_inactive");
- } else {
- $num_inactive = 0;
- }
-
- if ($num_inactive > 0) {
- $inactive_button = "<button dojoType=\"dijit.form.Button\"
- onclick=\"showInactiveFeeds()\">" .
- __("Inactive feeds") . "</button>";
- }
+ $inactive_button = "<button dojoType=\"dijit.form.Button\"
+ id=\"pref_feeds_inactive_btn\"
+ style=\"display : none\"
+ onclick=\"showInactiveFeeds()\">" .
+ __("Inactive feeds") . "</button>";
$feed_search = $this->dbh->escape_string($_REQUEST["search"]);
@@ -1433,6 +1414,8 @@ class Pref_Feeds extends Handler_Protected {
</script>
<script type=\"dojo/method\" event=\"onLoad\" args=\"item\">
Element.hide(\"feedlistLoading\");
+
+ checkInactiveFeeds();
</script>
</div>";
@@ -1970,5 +1953,20 @@ class Pref_Feeds extends Handler_Protected {
return $c;
}
+ function getinactivefeeds() {
+ if (DB_TYPE == "pgsql") {
+ $interval_qpart = "NOW() - INTERVAL '3 months'";
+ } else {
+ $interval_qpart = "DATE_SUB(NOW(), INTERVAL 3 MONTH)";
+ }
+
+ $result = $this->dbh->query("SELECT COUNT(*) AS num_inactive FROM ttrss_feeds WHERE
+ (SELECT MAX(updated) FROM ttrss_entries, ttrss_user_entries WHERE
+ ttrss_entries.id = ref_id AND
+ ttrss_user_entries.feed_id = ttrss_feeds.id) < $interval_qpart AND
+ ttrss_feeds.owner_uid = ".$_SESSION["uid"]);
+
+ print (int) $this->dbh->fetch_result($result, 0, "num_inactive");
+ }
}
?>
diff --git a/js/prefs.js b/js/prefs.js
index 67a4a378c..159b9ecbc 100644
--- a/js/prefs.js
+++ b/js/prefs.js
@@ -24,6 +24,20 @@ function updateFeedList(sort_key) {
} });
}
+function checkInactiveFeeds() {
+ try {
+ new Ajax.Request("backend.php", {
+ parameters: "?op=pref-feeds&method=getinactivefeeds",
+ onComplete: function(transport) {
+ if (parseInt(transport.responseText) > 0) {
+ Element.show(dijit.byId("pref_feeds_inactive_btn").domNode);
+ }
+ } });
+
+ } catch (e) {
+ exception_error("checkInactiveFeeds", e);
+ }
+}
function updateUsersList(sort_key) {
try {