aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornfebe <fenn25.fn@gmail.com>2025-08-07 07:18:37 +0100
committernfebe <fenn25.fn@gmail.com>2025-08-07 07:22:48 +0100
commit02c659c9dfc07249f5ccdb5d85aeb0bc6711419a (patch)
tree4b808ff9968fa8ca31777b83eb7fd0c7c61fbfaa
parentf0c392e21c930ecba18f5f31b93e8296082bade8 (diff)
downloadnextcloud-server-fix/smarter-loadmore-unified-search.tar.gz
nextcloud-server-fix/smarter-loadmore-unified-search.zip
fix(unified-search): Smarter load more buttonfix/smarter-loadmore-unified-search
This commit introduces a change to prevent showing the load more button, if the length of existing results is not equal to the requested limit (which implies it is less than because we never expect it to be more) Additionally, there is an enhancment to override provider filders passed to the find method. This would improve speed. Signed-off-by: nfebe <fenn25.fn@gmail.com>
-rw-r--r--core/src/components/UnifiedSearch/UnifiedSearchModal.vue17
1 files changed, 5 insertions, 12 deletions
diff --git a/core/src/components/UnifiedSearch/UnifiedSearchModal.vue b/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
index 002606f058b..b21c65301c4 100644
--- a/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
+++ b/core/src/components/UnifiedSearch/UnifiedSearchModal.vue
@@ -129,7 +129,7 @@
v-bind="result" />
</ul>
<div class="result-footer">
- <NcButton type="tertiary-no-background" @click="loadMoreResultsForProvider(providerResult)">
+ <NcButton v-if="providerResult.results.length === providerResult.limit" type="tertiary-no-background" @click="loadMoreResultsForProvider(providerResult)">
{{ t('core', 'Load more results') }}
<template #icon>
<IconDotsHorizontal :size="20" />
@@ -367,7 +367,7 @@ export default defineComponent({
this.$refs.searchInput?.focus()
})
},
- find(query: string) {
+ find(query: string, providersToSearchOverride = null) {
if (query.length === 0) {
this.results = []
this.searching = false
@@ -382,7 +382,7 @@ export default defineComponent({
this.searching = true
const newResults = []
- const providersToSearch = this.filteredProviders.length > 0 ? this.filteredProviders : this.providers
+ const providersToSearch = providersToSearchOverride || (this.filteredProviders.length > 0 ? this.filteredProviders : this.providers)
const searchProvider = (provider) => {
const params = {
type: provider.searchFrom ?? provider.id,
@@ -424,6 +424,7 @@ export default defineComponent({
newResults.push({
...provider,
results: response.data.ocs.data.entries,
+ limit: params.limit ?? 5,
})
unifiedSearchLogger.debug('Unified search results:', { results: this.results, newResults })
@@ -513,15 +514,7 @@ export default defineComponent({
},
async loadMoreResultsForProvider(provider) {
this.providerResultLimit += 5
- // Remove all other providers from filteredProviders except the current "loadmore" provider
- this.filteredProviders = this.filteredProviders.filter(filteredProvider => filteredProvider.id === provider.id)
- // Plugin filters may have extra parameters, so we need to keep them
- // See method handlePluginFilter for more details
- if (this.filteredProviders.length > 0 && this.filteredProviders[0].isPluginFilter) {
- provider = this.filteredProviders[0]
- }
- this.addProviderFilter(provider, true)
- this.find(this.searchQuery)
+ this.find(this.searchQuery, [provider])
},
addProviderFilter(providerFilter, loadMoreResultsForProvider = false) {
unifiedSearchLogger.debug('Applying provider filter', { providerFilter, loadMoreResultsForProvider })