From 769b755cd382e0baa6f9779738643361f660d435 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Fri, 24 May 2019 14:01:48 -0600 Subject: [PATCH] Make words re-sort when changing sortByDefinition --- src/js/dictionaryManagement.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/js/dictionaryManagement.js b/src/js/dictionaryManagement.js index bcc3642..5f7d803 100644 --- a/src/js/dictionaryManagement.js +++ b/src/js/dictionaryManagement.js @@ -2,7 +2,7 @@ import { renderDictionaryDetails, renderPartsOfSpeech, renderAll } from "./rende import { removeTags, cloneObject, getTimestampInSeconds, download, slugify } from "../helpers"; import { LOCAL_STORAGE_KEY, DEFAULT_DICTIONARY, MIGRATE_VERSION } from "../constants"; import { addMessage, getNextId, hasToken } from "./utilities"; -import { addWord } from "./wordManagement"; +import { addWord, sortWords } from "./wordManagement"; export function updateDictionary () { @@ -60,6 +60,7 @@ export function saveEditModal() { window.currentDictionary.settings.allowDuplicates = !document.getElementById('editPreventDuplicates').checked; window.currentDictionary.settings.caseSensitive = document.getElementById('editCaseSensitive').checked; + const needsReSort = window.currentDictionary.settings.sortByDefinition !== document.getElementById('editSortByDefinition').checked; window.currentDictionary.settings.sortByDefinition = document.getElementById('editSortByDefinition').checked; window.currentDictionary.settings.isComplete = document.getElementById('editIsComplete').checked; window.currentDictionary.settings.isPublic = document.getElementById('editIsPublic').checked; @@ -69,6 +70,10 @@ export function saveEditModal() { renderDictionaryDetails(); renderPartsOfSpeech(); + if (needsReSort) { + sortWords(true); + } + if (hasToken()) { import('./account/index.js').then(account => { account.uploadDetailsDirect();