diff options
author | Andrew Dolgov <[email protected]> | 2018-12-11 08:48:24 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-12-11 08:48:24 +0300 |
commit | fd6f3e7f073beb648ee25e08263ea9b1e6149947 (patch) | |
tree | 82a58c6006183230793df2c3b3ba37ed6842d0ed /js/Headlines.js | |
parent | 7cfd04ffb4ed2cf7687dd0449d8cc62103fd59a0 (diff) |
syncModified: request counters once after all xhr promises resolve
Diffstat (limited to 'js/Headlines.js')
-rwxr-xr-x | js/Headlines.js | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/js/Headlines.js b/js/Headlines.js index 0c0a7f56a..1db858bb7 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -99,31 +99,30 @@ define(["dojo/_base/declare"], function (declare) { cb.attr('checked', false); }); + const promises = []; + if (ops.tmark.length != 0) - xhrPost("backend.php", - { op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2}, (transport) => { - App.handleRpcJson(transport); - }); + promises.push(xhrPost("backend.php", + { op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2})); if (ops.tpub.length != 0) - xhrPost("backend.php", - { op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2}, (transport) => { - App.handleRpcJson(transport); - }); + promises.push(xhrPost("backend.php", + { op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2})); if (ops.read.length != 0) - xhrPost("backend.php", - { op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0}, (transport) => { - App.handleRpcJson(transport); - }); + promises.push(xhrPost("backend.php", + { op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0})); if (ops.unread.length != 0) - xhrPost("backend.php", - { op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1}, (transport) => { - App.handleRpcJson(transport); - }); + promises.push(xhrPost("backend.php", + { op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1})); + + if (promises.length > 0) + Promise.all([promises]).then(() => { + Feeds.requestCounters(true); + }); - }, + }, click: function (event, id, in_body) { in_body = in_body || false; |