Update addWords() to not save; Update importWords to save after complete
This commit is contained in:
parent
8c92e56312
commit
b2db35982f
|
@ -245,13 +245,18 @@ export function importWords() {
|
|||
definition: removeTags(row.definition).trim(),
|
||||
details: removeTags(row.explanation).trim(),
|
||||
wordId: getNextId(),
|
||||
}, false, false, false);
|
||||
}, false);
|
||||
|
||||
importedWords.push(importedWord);
|
||||
|
||||
// Sort and save every 500 words, just in case something goes wrong on large imports
|
||||
if (importedWords.length % 500 == 499) {
|
||||
sortWords(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
complete: () => {
|
||||
saveDictionary(false);
|
||||
sortWords(false);
|
||||
renderAll();
|
||||
importWordsField.value = '';
|
||||
document.getElementById('editModal').style.display = 'none';
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { addWord } from './wordManagement';
|
||||
import { getCookie } from './StackOverflow/cookie';
|
||||
|
||||
export function getNextId() {
|
||||
|
|
|
@ -173,6 +173,14 @@ export function submitWordForm() {
|
|||
|
||||
if (validateWord(word)) {
|
||||
addWord(word);
|
||||
sortWords(true);
|
||||
|
||||
if (upload && hasToken()) {
|
||||
import('./account/index.js').then(account => {
|
||||
account.uploadWord(word);
|
||||
});
|
||||
}
|
||||
|
||||
clearWordForm();
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +195,7 @@ export function clearWordForm() {
|
|||
document.getElementById('wordName').focus();
|
||||
}
|
||||
|
||||
export function addWord(word, render = true, message = true, upload = true) {
|
||||
export function addWord(word, message = true) {
|
||||
const timestamp = getTimestampInSeconds();
|
||||
word.lastUpdated = timestamp;
|
||||
word.createdOn = timestamp;
|
||||
|
@ -195,13 +203,6 @@ export function addWord(word, render = true, message = true, upload = true) {
|
|||
if (message) {
|
||||
addMessage(`<a href="#${word.wordId}">${word.name}</a> Created Successfully`, 30000);
|
||||
}
|
||||
sortWords(render);
|
||||
|
||||
if (upload && hasToken()) {
|
||||
import('./account/index.js').then(account => {
|
||||
account.uploadWord(word);
|
||||
});
|
||||
}
|
||||
|
||||
return word;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue