gettext("Action '{0}' for '{1}' items"),
action, selected.length,
),
- function(button) {
+ async function(button) {
if (button !== 'yes') {
return;
}
- PMG.Utils.doQuarantineAction(action, idlist.join(';'), function() {
- list.getController().load();
- });
+ list.mask(gettext('Processing...'), 'x-mask-loading');
+
+ const sliceSize = 2500, maxInFlight = 2;
+ let batches = [], batchCount = Math.ceil(selected.length / sliceSize);
+ for (let i = 0; i * sliceSize < selected.length; i++) {
+ let sliceStart = i * sliceSize;
+ let sliceEnd = Math.min(sliceStart + sliceSize, selected.length);
+ batches.push(
+ PMG.Async.doQAction(
+ action,
+ idlist.slice(sliceStart, sliceEnd),
+ i + 1,
+ batchCount,
+ ),
+ );
+ if (batches.length >= maxInFlight) {
+ await Promise.allSettled(batches); // eslint-disable-line no-await-in-loop
+ batches = [];
+ }
+ }
+ await Promise.allSettled(batches); // await possible remaining ones
+ list.unmask();
+ // below can be slow, we could remove directly from the in-memory store, but
+ // with lots of elements and some failures we could be quite out of sync?
+ list.getController().load();
},
);
return;
}
PMG.Utils.doQuarantineAction(action, selected[0].data.id, function() {
- list.getController().load();
+ // success -> remove directly to avoid slow store reload for a single-element action
+ list.getStore().remove(selected[0]);
+ list.getController().restoreSavedSelection();
});
},
openContextMenu: function(table, record, tr, index, event) {
event.stopEvent();
- var me = this;
- var list = me.lookup('list');
- var menu = Ext.create('PMG.menu.SpamContextMenu', {
- callback: function(action) {
- me.doAction(action, list.getSelection());
- },
- });
-
- menu.showAt(event.getXY());
+ let me = this;
+ let list = me.lookup('list');
+ Ext.create('PMG.menu.SpamContextMenu', {
+ callback: action => me.doAction(action, list.getSelection()),
+ }).showAt(event.getXY());
},
keyPress: function(table, record, item, index, event) {