fix(unified-search): filteredProviders now inherits all provider props

The main providers come from both the backend and client side plugins such as `in-folder` search.
The main providers may carry callbacks functions and other information that should be passed to the `filteredProviders`.
This is important because the current code does not make a distinction between `filteredProviders` and `providers`
rightly so, becuase they are the same thing!

Without the mentioned distinction above, sooner or later, we try to access a property on the `filteredProviders` which we
did not transfer with the manual property copy.

----

This fix prevents in-folder search from searching everywhere when "load more results" is clicked; Essentially ignoring the in-folder
search filter.

Signed-off-by: nfebe <fenn25.fn@gmail.com>
pull/50631/head
nfebe 2025-01-31 14:45:29 +07:00 committed by backportbot[bot]
parent 6a55819e71
commit ab9dbe048e
1 changed files with 6 additions and 6 deletions

@ -507,6 +507,11 @@ export default defineComponent({
// If load more result for filter, remove other filters
this.filters = this.filters.filter(filter => filter.id === provider.id)
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)
},
addProviderFilter(providerFilter, loadMoreResultsForProvider = false) {
@ -531,13 +536,8 @@ export default defineComponent({
this.filters = this.syncProviderFilters(this.filters, this.filteredProviders)
}
this.filteredProviders.push({
id: providerFilter.id,
appId: providerFilter.appId,
searchFrom: providerFilter.searchFrom,
name: providerFilter.name,
icon: providerFilter.icon,
...providerFilter,
type: providerFilter.type || 'provider',
filters: providerFilter.filters,
isPluginFilter: providerFilter.isPluginFilter || false,
})
this.filters = this.syncProviderFilters(this.filters, this.filteredProviders)