only request counters once for headline mutations
This commit is contained in:
parent
e468e5a589
commit
9ad5f04e51
|
@ -149,38 +149,51 @@ const Headlines = {
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
|
||||||
if (ops.tmark.length != 0)
|
if (ops.tmark.length != 0)
|
||||||
promises.push(xhr.json("backend.php",
|
promises.push(xhr.post("backend.php",
|
||||||
{op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2}));
|
{op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2}));
|
||||||
|
|
||||||
if (ops.tpub.length != 0)
|
if (ops.tpub.length != 0)
|
||||||
promises.push(xhr.json("backend.php",
|
promises.push(xhr.post("backend.php",
|
||||||
{op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2}));
|
{op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2}));
|
||||||
|
|
||||||
if (ops.read.length != 0)
|
if (ops.read.length != 0)
|
||||||
promises.push(xhr.json("backend.php",
|
promises.push(xhr.post("backend.php",
|
||||||
{op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0}));
|
{op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0}));
|
||||||
|
|
||||||
if (ops.unread.length != 0)
|
if (ops.unread.length != 0)
|
||||||
promises.push(xhr.json("backend.php",
|
promises.push(xhr.post("backend.php",
|
||||||
{op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1}));
|
{op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1}));
|
||||||
|
|
||||||
const scores = Object.keys(ops.rescore);
|
const scores = Object.keys(ops.rescore);
|
||||||
|
|
||||||
if (scores.length != 0) {
|
if (scores.length != 0) {
|
||||||
scores.forEach((score) => {
|
scores.forEach((score) => {
|
||||||
promises.push(xhr.json("backend.php",
|
promises.push(xhr.post("backend.php",
|
||||||
{op: "article", method: "setScore", id: ops.rescore[score].toString(), score: score}));
|
{op: "article", method: "setScore", id: ops.rescore[score].toString(), score: score}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (promises.length > 0)
|
Promise.all(promises).then((results) => {
|
||||||
Promise.all([promises]).then(() => {
|
let feeds = [];
|
||||||
window.clearTimeout(this._observer_counters_timeout);
|
|
||||||
|
|
||||||
this._observer_counters_timeout = setTimeout(() => {
|
results.forEach((res) => {
|
||||||
Feeds.requestCounters();
|
if (res) {
|
||||||
}, 1000);
|
try {
|
||||||
});*/
|
const obj = JSON.parse(res);
|
||||||
|
|
||||||
|
if (obj.feeds)
|
||||||
|
feeds = feeds.concat(obj.feeds);
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(e, res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (feeds.length > 0)
|
||||||
|
console.log('requesting counters for', feeds);
|
||||||
|
Feeds.requestCounters(feeds);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
},
|
},
|
||||||
click: function (event, id, in_body) {
|
click: function (event, id, in_body) {
|
||||||
|
|
Loading…
Reference in New Issue