Choose when saveDictionary() updates lastUpdated

This commit is contained in:
Robbie Antenesse 2019-05-23 14:26:57 -06:00
parent c5bdfa5450
commit 569a0b9fc5
3 changed files with 9 additions and 7 deletions

View File

@ -94,7 +94,7 @@ export function uploadWholeDictionary(asNew = false) {
dictionary,
}, remoteId => {
window.currentDictionary.externalID = remoteId;
saveDictionary();
saveDictionary(false);
addMessage('Dictionary Uploaded Successfully');
}, errorData => {
console.error(errorData);
@ -120,7 +120,7 @@ export function syncDetails(remoteDetails = false) {
return uploadDetails();
} else if (direction === 'down') {
window.currentDictionary = Object.assign(window.currentDictionary, remoteDetails);
saveDictionary();
saveDictionary(false);
}
addMessage('Dictionary details synchronized');
return Promise.resolve(true);
@ -173,7 +173,7 @@ export function syncWords(remoteWords, deletedWords) {
window.currentDictionary.words = words;
sortWords();
saveDictionary();
saveDictionary(false);
if (localWordsToUpload.length > 0) {
return uploadWords(words);

View File

@ -81,8 +81,10 @@ export function saveAndCloseEditModal() {
document.getElementById('editModal').style.display = 'none';
}
export function saveDictionary() {
window.currentDictionary.lastUpdated = getTimestampInSeconds();
export function saveDictionary(triggerLastUpdated = true) {
if (triggerLastUpdated) {
window.currentDictionary.lastUpdated = getTimestampInSeconds();
}
window.localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify(window.currentDictionary));
}
@ -185,7 +187,7 @@ export function importWords() {
}
},
complete: () => {
saveDictionary();
saveDictionary(false);
renderAll();
importWordsField.value = '';
document.getElementById('editModal').style.display = 'none';

View File

@ -39,7 +39,7 @@ export function sortWords(render) {
return removeDiacritics(wordA[sortBy]).toLowerCase() > removeDiacritics(wordB[sortBy]).toLowerCase() ? 1 : -1;
});
saveDictionary();
saveDictionary(false);
if (render) {
renderWords();