syncModified: request counters once after all xhr promises resolve

This commit is contained in:
Andrew Dolgov 2018-12-11 08:48:24 +03:00
parent 7cfd04ffb4
commit fd6f3e7f07
1 changed files with 16 additions and 17 deletions

View File

@ -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;