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

View File

@ -99,31 +99,30 @@ define(["dojo/_base/declare"], function (declare) {
cb.attr('checked', false); cb.attr('checked', false);
}); });
const promises = [];
if (ops.tmark.length != 0) if (ops.tmark.length != 0)
xhrPost("backend.php", promises.push(xhrPost("backend.php",
{ op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2}, (transport) => { { op: "rpc", method: "markSelected", ids: ops.tmark.toString(), cmode: 2}));
App.handleRpcJson(transport);
});
if (ops.tpub.length != 0) if (ops.tpub.length != 0)
xhrPost("backend.php", promises.push(xhrPost("backend.php",
{ op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2}, (transport) => { { op: "rpc", method: "publishSelected", ids: ops.tpub.toString(), cmode: 2}));
App.handleRpcJson(transport);
});
if (ops.read.length != 0) if (ops.read.length != 0)
xhrPost("backend.php", promises.push(xhrPost("backend.php",
{ op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0}, (transport) => { { op: "rpc", method: "catchupSelected", ids: ops.read.toString(), cmode: 0}));
App.handleRpcJson(transport);
});
if (ops.unread.length != 0) if (ops.unread.length != 0)
xhrPost("backend.php", promises.push(xhrPost("backend.php",
{ op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1}, (transport) => { { op: "rpc", method: "catchupSelected", ids: ops.unread.toString(), cmode: 1}));
App.handleRpcJson(transport);
});
}, if (promises.length > 0)
Promise.all([promises]).then(() => {
Feeds.requestCounters(true);
});
},
click: function (event, id, in_body) { click: function (event, id, in_body) {
in_body = in_body || false; in_body = in_body || false;