Skip to content

Commit

Permalink
fix(unified-search): filteredProviders now inherits all provider props
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
nfebe committed Feb 3, 2025
1 parent e9cb614 commit d2fc45a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions core/src/components/UnifiedSearch/UnifiedSearchModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit d2fc45a

Please sign in to comment.