From fabec4dd7e873335e9e2bf2906514dbd1ccb3b8d Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Tue, 7 Nov 2023 02:26:50 +0000 Subject: [PATCH] Even faster search --- cista-front/src/views/ExplorerView.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cista-front/src/views/ExplorerView.vue b/cista-front/src/views/ExplorerView.vue index 0342114..b163caa 100644 --- a/cista-front/src/views/ExplorerView.vue +++ b/cista-front/src/views/ExplorerView.vue @@ -25,11 +25,16 @@ const documents = computed(() => { // List the current location if (!documentStore.search) return documentStore.document.filter(doc => doc.loc === loc) // Find up to 100 newest documents that match the search - let docs = documentStore.recentDocuments const search = documentStore.search - console.log('Searching for', search) const needle = needleFormat(search) - docs = docs.filter(doc => localeIncludes(doc.haystack, needle)).slice(0, 100) + let limit = 100 + let docs = [] + for (const doc of documentStore.recentDocuments) { + if (localeIncludes(doc.haystack, needle)) { + docs.push(doc) + if (--limit === 0) break + } + } // Organize by folder, by relevance const locsub = loc + '/' docs.sort((a, b) => (