Fix updateSort part deux

This commit is contained in:
Rob Garrison 2017-12-23 22:22:39 -06:00
parent cedf2fd691
commit 5eeb0c82ea
2 changed files with 17 additions and 12 deletions

View File

@ -155,8 +155,8 @@ function filterOnChange({target: el, forceRefilter}) {
}); });
if (installed) { if (installed) {
reapplyFilter(); reapplyFilter();
sorter().updateSort();
} }
sorter().updateSort();
} }

View File

@ -144,18 +144,23 @@ const sorter = (() => {
} }
function updateSort() { function updateSort() {
getStylesSafe().then(styles => { if (!installed) return;
const renderBin = document.createDocumentFragment(); const current = [...installed.children];
const entries = sortStyles(styles); const sorted = sortStyles({
const current = [...installed.children]; styles: current.map(entry => ({
const isDiffSort = entries.length !== current.length || entry,
current.find((entry, index) => entry.id !== entries[index].id); name: entry.styleNameLowerCase,
if (isDiffSort) { style: BG.cachedStyles.byId.get(entry.styleId),
entries.forEach(entry => renderBin.appendChild(entry)); }))
installed.appendChild(renderBin);
updateStripes();
}
}); });
const isDiffSort = sorted.length !== current.length ||
current.find((entry, index) => entry !== sorted[index].entry);
if (isDiffSort) {
const renderBin = document.createDocumentFragment();
sorted.forEach(({entry}) => renderBin.appendChild(entry));
installed.appendChild(renderBin);
updateStripes();
}
} }
function manageSort(event) { function manageSort(event) {