sorting optimization
This commit is contained in:
parent
55bf3123f9
commit
acee884967
1 changed files with 9 additions and 4 deletions
|
@ -61,17 +61,19 @@
|
|||
let sortedAttributes = entries;
|
||||
|
||||
let sortKeys: { [key: string]: string[] } = {};
|
||||
function addSortKeys(key: string, vals: string[]) {
|
||||
function addSortKeys(key: string, vals: string[], resort = true) {
|
||||
if (!sortKeys[key]) {
|
||||
sortKeys[key] = [];
|
||||
}
|
||||
let changed = false;
|
||||
vals.forEach((val) => {
|
||||
if (!sortKeys[key].includes(val)) {
|
||||
changed = true;
|
||||
sortKeys[key].push(val);
|
||||
}
|
||||
});
|
||||
|
||||
sortAttributes();
|
||||
|
||||
if (resort && changed) sortAttributes();
|
||||
}
|
||||
|
||||
function sortAttributes() {
|
||||
|
@ -140,11 +142,14 @@
|
|||
if (entry.value.t === "Address") {
|
||||
addSortKeys(
|
||||
String(entry.value.c),
|
||||
entry.listing.getObject(String(entry.value.c)).identify()
|
||||
entry.listing.getObject(String(entry.value.c)).identify(),
|
||||
false
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
sortAttributes();
|
||||
|
||||
// Navigation highlights
|
||||
const { index } = getContext("browse") as { index: Writable<number> };
|
||||
$: addresses = $params.addresses.split(",");
|
||||
|
|
Loading…
Reference in a new issue