WIP
This commit is contained in:
parent
a9eea9f634
commit
253da36755
@ -153,13 +153,14 @@ class Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Promise.all([termCounter, kanjiCounter]).then(([termCount, kanjiCount]) => {
|
return Promise.all([termCounter, kanjiCounter]).then(([termCount, kanjiCount]) => {
|
||||||
|
const rowLimit = 500;
|
||||||
const totalCount = termCount + kanjiCount;
|
const totalCount = termCount + kanjiCount;
|
||||||
let deletedCount = 0;
|
let deletedCount = 0;
|
||||||
|
|
||||||
let termDeleter = Promise.resolve();
|
let termDeleter = Promise.resolve();
|
||||||
if (info.hasTerms) {
|
if (info.hasTerms) {
|
||||||
const termDeleterFunc = () => {
|
const termDeleterFunc = () => {
|
||||||
return this.db.terms.where('dictionary').equals(title).limit(500).delete().then(count => {
|
return this.db.terms.where('dictionary').equals(title).limit(rowLimit).delete().then(count => {
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
@ -179,7 +180,7 @@ class Database {
|
|||||||
let kanjiDeleter = Promise.resolve();
|
let kanjiDeleter = Promise.resolve();
|
||||||
if (info.hasKanji) {
|
if (info.hasKanji) {
|
||||||
const kanjiDeleterFunc = () => {
|
const kanjiDeleterFunc = () => {
|
||||||
return this.db.kanji.where('dictionary').equals(title).limit(500).delete().then(count => {
|
return this.db.kanji.where('dictionary').equals(title).limit(rowLimit).delete().then(count => {
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
@ -158,15 +158,17 @@ function onDictionaryImport() {
|
|||||||
const dictSpinner = $('#dict-spinner');
|
const dictSpinner = $('#dict-spinner');
|
||||||
dictSpinner.show();
|
dictSpinner.show();
|
||||||
|
|
||||||
const callback = (total, current) => {
|
const setProgress = percent => {
|
||||||
dictProgress.find('div').css('width', `${current / total * 100.0}%`);
|
dictProgress.find('div').css('width', `${percent}%`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setProgress(0.0);
|
||||||
|
|
||||||
const dictUrl = $('#dict-url');
|
const dictUrl = $('#dict-url');
|
||||||
loadOptions().then(opts => {
|
loadOptions().then(opts => {
|
||||||
database().importDictionary(dictUrl.val(), callback).then(summary => {
|
database().importDictionary(dictUrl.val(), (total, current) => setProgress(current / total * 100.0)).then(summary => {
|
||||||
opts.dictionaries[summary.title] = {enableTerms: summary.hasTerms, enableKanji: summary.hasKanji};
|
opts.dictionaries[summary.title] = {enableTerms: summary.hasTerms, enableKanji: summary.hasKanji};
|
||||||
return saveOptions(opts);
|
return saveOptions(opts).then(() => yomichan().setOptions(opts));
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return populateDictionaries(opts);
|
return populateDictionaries(opts);
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
|
Loading…
Reference in New Issue
Block a user