Browse Source

get waiting task function improved

master
master 11 months ago
parent
commit
fbd773354d
  1. 51
      heroUnion.mjs

51
heroUnion.mjs

@ -144,52 +144,29 @@ class HeroUnion {
getWaitingTask(platform, country, lang, data_mode) { getWaitingTask(platform, country, lang, data_mode) {
let searchResult = null; let searchResult = null;
for (const task of this.tasks) { let taskIndex = this.tasks.findIndex(function(item) {
if (searchResult) {break;} if (typeof(platform) != 'undefined' && platform && item.platform != platform) {
return false;
if (task.status == 'waiting') {
if (typeof(platform) != 'undefined' && platform) {
if (platform == task.platform) {
searchResult = task;
}else {
searchResult = null;
continue;
}
} }
if (typeof(country) != 'undefined' && country) { if (typeof(country) != 'undefined' && country && item.country != country) {
if (country == task.country) { return false;
searchResult = task;
}else {
searchResult = null;
continue;
}
} }
if (typeof(lang) != 'undefined' && lang) { if (typeof(lang) != 'undefined' && lang && item.lang != lang) {
if (lang == task.lang) { return false;
searchResult = task;
}else {
searchResult = null;
continue;
}
} }
if (typeof(data_mode) != 'undefined' && data_mode) { if (typeof(data_mode) != 'undefined' && data_mode && task.data_mode != data_mode) {
if (data_mode == task.data_mode) { return false;
searchResult = task;
}else {
searchResult = null;
continue;
}
}
}
} }
if (searchResult) { return true;
let taskIndex = this.tasks.findIndex((item) => item.id == searchResult.id); });
if (taskIndex > -1) {
this.tasks[taskIndex].status = 'running'; this.tasks[taskIndex].status = 'running';
searchResult.status = 'running'; searchResult = this.tasks[taskIndex];
} }
return searchResult; return searchResult;

Loading…
Cancel
Save