From 299e7cf5cf87aedf53b97d002545031de49fc9b9 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 6 Jul 2024 01:06:50 +0200 Subject: [PATCH] fix: improve performance of content search for large repos --- .../src/lib/components/ContentSearch.svelte | 66 +++++++++++++++++-- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/frontend/src/lib/components/ContentSearch.svelte b/frontend/src/lib/components/ContentSearch.svelte index 659f833f1c..4dc722363b 100644 --- a/frontend/src/lib/components/ContentSearch.svelte +++ b/frontend/src/lib/components/ContentSearch.svelte @@ -103,6 +103,20 @@ flows: getCounts(filteredFlowItems.length), scripts: getCounts(filteredScriptItems.length) } + + let showNbScripts = 10 + let showNbApps = 10 + let showNbResources = 10 + let showNbFlows = 10 + + $: search && resetShows() + + function resetShows() { + showNbScripts = 10 + showNbApps = 10 + showNbResources = 10 + showNbFlows = 10 + } 0}
{#if (searchKind == 'all' || searchKind == 'scripts') && filteredScriptItems?.length > 0} - {#each filteredScriptItems ?? [] as item} + {#each filteredScriptItems.slice(0, showNbScripts) ?? [] as item}
{/each} + {#if filteredScriptItems.length > showNbScripts} + { + showNbScripts += 30 + }} + > + ({showNbScripts} of {filteredScriptItems.length}) Show more scripts + + {/if} {/if} {#if (searchKind == 'all' || searchKind == 'resources') && filteredResourceItems?.length > 0} - {#each filteredResourceItems ?? [] as item} + {#each filteredResourceItems.slice(0, showNbResources) ?? [] as item}
Resource: {item.path}
@@ -320,9 +345,20 @@
{/each} + {#if filteredResourceItems.length > showNbResources} + { + showNbResources += 30 + }} + > + ({showNbResources} of {filteredResourceItems.length}) Show more resources + + {/if} {/if} {#if (searchKind == 'all' || searchKind == 'flows') && filteredFlowItems?.length > 0} - {#each filteredFlowItems ?? [] as item} + {#each filteredFlowItems.slice(0, showNbFlows) ?? [] as item}
+ {#if filteredFlowItems.length > showNbFlows} + { + showNbScripts += 30 + }} + > + ({showNbFlows} of {filteredFlowItems.length}) Show more flows + + {/if} {/each} {/if} {#if (searchKind == 'all' || searchKind == 'apps') && filteredAppItems?.length > 0} - {#each filteredAppItems ?? [] as item} + {#each filteredAppItems.slice(0, showNbApps) ?? [] as item}
{/each} + {#if filteredAppItems.length > showNbApps} + { + showNbApps += 30 + }} + > + ({showNbApps} of {filteredAppItems.length}) Show more apps + + {/if} {/if} {:else}