From 0d5e201ff2bd9901c53d1e7fbbe81fc12f1d956a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sat, 17 Dec 2022 19:07:31 +0100 Subject: [PATCH] perf: only resort once initial query has finished --- webui/src/components/widgets/EntryList.svelte | 13 ++++++------- webui/src/components/widgets/Gallery.svelte | 4 +++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/webui/src/components/widgets/EntryList.svelte b/webui/src/components/widgets/EntryList.svelte index 0033aed..2c03231 100644 --- a/webui/src/components/widgets/EntryList.svelte +++ b/webui/src/components/widgets/EntryList.svelte @@ -88,9 +88,10 @@ // Sorting let sortedAttributes = entries; + let resort = false; let sortKeys: { [key: string]: string[] } = {}; - function addSortKeys(key: string, vals: string[], resort = true) { + function addSortKeys(key: string, vals: string[]) { if (!sortKeys[key]) { sortKeys[key] = []; } @@ -116,19 +117,18 @@ entries.forEach((entry) => { addSortKeys( entry.entity, - $labelListing.getObject(entry.entity).identify(), - false + $labelListing.getObject(entry.entity).identify() ); if (entry.value.t === "Address") { addSortKeys( entry.value.c, - $labelListing.getObject(String(entry.value.c)).identify(), - false + $labelListing.getObject(String(entry.value.c)).identify() ); } }); sortAttributes(); + resort = true; } } @@ -137,8 +137,7 @@ if (entry.value.t === "Address") { addSortKeys( entry.value.c, - entry.listing.getObject(String(entry.value.c)).identify(), - false + entry.listing.getObject(String(entry.value.c)).identify() ); } }); diff --git a/webui/src/components/widgets/Gallery.svelte b/webui/src/components/widgets/Gallery.svelte index e515a5e..2cef4c6 100644 --- a/webui/src/components/widgets/Gallery.svelte +++ b/webui/src/components/widgets/Gallery.svelte @@ -20,9 +20,10 @@ // Sorting let sortedEntities = deduplicatedEntities || []; + let resort = false; let sortKeys: { [key: string]: string[] } = {}; - function addSortKeys(key: string, vals: string[], resort = true) { + function addSortKeys(key: string, vals: string[]) { if (!sortKeys[key]) { sortKeys[key] = []; } @@ -80,6 +81,7 @@ addSortKeys(address, $labelListing.getObject(address).identify()); }); sortAttributes(); + resort = true; } }