Progress update
This commit is contained in:
parent
ff3896ed01
commit
b9d53f8427
@ -163,7 +163,7 @@ class Dictionary {
|
|||||||
|
|
||||||
return this.db.terms.bulkAdd(rows).then(() => {
|
return this.db.terms.bulkAdd(rows).then(() => {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(indexUrl, i, index.banks);
|
callback(i, index.banks, indexUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -199,7 +199,7 @@ class Dictionary {
|
|||||||
|
|
||||||
return this.db.kanji.bulkAdd(rows).then(() => {
|
return this.db.kanji.bulkAdd(rows).then(() => {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(indexUrl, i, index.banks);
|
callback(i, index.banks, indexUrl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -46,21 +46,18 @@ class Translator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const banks = {};
|
const banks = {};
|
||||||
const bankCallback = (indexUrl, loaded, total) => {
|
const bankCallback = (loaded, total, indexUrl) => {
|
||||||
banks[indexUrl] = {loaded: loaded, total: total};
|
banks[indexUrl] = {loaded, total};
|
||||||
if (Object.keys(banks).length !== 3) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let banksLoaded = 0;
|
let percent = 0.0;
|
||||||
let banksTotal = 0;
|
|
||||||
for (const url in banks) {
|
for (const url in banks) {
|
||||||
banksLoaded += banks[url].loaded;
|
percent += banks[url].loaded / banks[url].total;
|
||||||
banksTotal += banks[url].total;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback && banksTotal > 0) {
|
percent /= 3;
|
||||||
callback({state: 'update', progress: Math.ceil(100 * banksLoaded / banksTotal)});
|
|
||||||
|
if (callback) {
|
||||||
|
callback({state: 'update', progress: Math.ceil(100 * percent)});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user