mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
fix(unified-search): Smarter load more button
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>
This commit is contained in:
parent
3dac5b33ee
commit
7fbf997420
1 changed files with 5 additions and 12 deletions
|
|
@ -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 })
|
||||
|
|
|
|||
Loading…
Reference in a new issue