requestCounters: remove cooldown
This commit is contained in:
parent
5807f2e0f0
commit
d53cdaf815
|
@ -271,16 +271,13 @@ class RPC extends Handler_Protected {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllCounters() {
|
function getAllCounters() {
|
||||||
$last_article_id = (int) clean($_REQUEST["last_article_id"]);
|
@$seq = (int) $_REQUEST['seq'];
|
||||||
|
|
||||||
$reply = array();
|
$reply = [
|
||||||
|
'counters' => Counters::getAllCounters()
|
||||||
if (!empty($_REQUEST['seq'])) $reply['seq'] = (int) $_REQUEST['seq'];
|
];
|
||||||
|
|
||||||
if ($last_article_id != Article::getLastArticleId()) {
|
|
||||||
$reply['counters'] = Counters::getAllCounters();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if ($seq % 2 == 0)
|
||||||
$reply['runtime-info'] = make_runtime_info();
|
$reply['runtime-info'] = make_runtime_info();
|
||||||
|
|
||||||
print json_encode($reply);
|
print json_encode($reply);
|
||||||
|
|
|
@ -1305,10 +1305,7 @@
|
||||||
|
|
||||||
$data["max_feed_id"] = (int) $max_feed_id;
|
$data["max_feed_id"] = (int) $max_feed_id;
|
||||||
$data["num_feeds"] = (int) $num_feeds;
|
$data["num_feeds"] = (int) $num_feeds;
|
||||||
|
|
||||||
$data['last_article_id'] = Article::getLastArticleId();
|
|
||||||
$data['cdm_expanded'] = get_pref('CDM_EXPANDED');
|
$data['cdm_expanded'] = get_pref('CDM_EXPANDED');
|
||||||
|
|
||||||
$data["labels"] = Labels::get_all_labels($_SESSION["uid"]);
|
$data["labels"] = Labels::get_all_labels($_SESSION["uid"]);
|
||||||
|
|
||||||
if (LOG_DESTINATION == 'sql' && $_SESSION['access_level'] >= 10) {
|
if (LOG_DESTINATION == 'sql' && $_SESSION['access_level'] >= 10) {
|
||||||
|
|
|
@ -218,7 +218,6 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
|
|
||||||
if (message == "UPDATE_COUNTERS") {
|
if (message == "UPDATE_COUNTERS") {
|
||||||
console.log("need to refresh counters...");
|
console.log("need to refresh counters...");
|
||||||
App.setInitParam("last_article_id", -1);
|
|
||||||
Feeds.requestCounters(true);
|
Feeds.requestCounters(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
js/Feeds.js
21
js/Feeds.js
|
@ -120,27 +120,10 @@ define(["dojo/_base/declare"], function (declare) {
|
||||||
this._search_query = "";
|
this._search_query = "";
|
||||||
this.reloadCurrent();
|
this.reloadCurrent();
|
||||||
},
|
},
|
||||||
requestCounters: function(force) {
|
requestCounters: function() {
|
||||||
const date = new Date();
|
xhrPost("backend.php", {op: "rpc", method: "getAllCounters", seq: App.next_seq()}, (transport) => {
|
||||||
const timestamp = Math.round(date.getTime() / 1000);
|
|
||||||
|
|
||||||
if (force || timestamp - this.counters_last_request > 5) {
|
|
||||||
console.log("scheduling request of counters...");
|
|
||||||
|
|
||||||
this.counters_last_request = timestamp;
|
|
||||||
|
|
||||||
let query = {op: "rpc", method: "getAllCounters", seq: App.next_seq()};
|
|
||||||
|
|
||||||
if (!force)
|
|
||||||
query.last_article_id = App.getInitParam("last_article_id");
|
|
||||||
|
|
||||||
xhrPost("backend.php", query, (transport) => {
|
|
||||||
App.handleRpcJson(transport);
|
App.handleRpcJson(transport);
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log("request_counters: rate limit reached: " + (timestamp - this.counters_last_request));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
reload: function() {
|
reload: function() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue