Skip to content

Commit c0297b7

Browse files
committed
fix(unified-search): add missing supportsActiveFilters calculation
The supportsActiveFilters variable was used but never defined, causing the filtered/unfiltered results separation to fail silently. Signed-off-by: nfebe <[email protected]>
1 parent 9f1027b commit c0297b7

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

core/src/components/UnifiedSearch/UnifiedSearchModal.vue

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,20 +508,30 @@ export default defineComponent({
508508
509509
// This block of filter checks should be dynamic somehow and should be handled in
510510
// nextcloud/search lib
511-
const activeFilters = this.filters.filter(filter => {
511+
const contentFilterTypes = this.filters
512+
.filter((f) => f.type !== 'provider')
513+
.map((f) => f.type)
514+
const supportsActiveFilters = contentFilterTypes.length === 0
515+
|| contentFilterTypes.every((type) => this.providerIsCompatibleWithFilters(provider, [type]))
516+
517+
const baseProvider = provider.searchFrom
518+
? this.providers.find((p) => p.id === provider.searchFrom) ?? provider
519+
: provider
520+
521+
const activeFilters = this.filters.filter((filter) => {
512522
return filter.type !== 'provider' && this.providerIsCompatibleWithFilters(provider, [filter.type])
513523
})
514524
515-
activeFilters.forEach(filter => {
525+
activeFilters.forEach((filter) => {
516526
switch (filter.type) {
517527
case 'date':
518-
if (provider.filters?.since && provider.filters?.until) {
528+
if (baseProvider.filters?.since && baseProvider.filters?.until) {
519529
params.since = this.dateFilter.startFrom
520530
params.until = this.dateFilter.endAt
521531
}
522532
break
523533
case 'person':
524-
if (provider.filters?.person) {
534+
if (baseProvider.filters?.person) {
525535
params.person = this.personFilter.user
526536
}
527537
break
@@ -820,8 +830,20 @@ export default defineComponent({
820830
821831
return flattenedArray
822832
},
823-
async providerIsCompatibleWithFilters(provider, filterIds) {
824-
return filterIds.every(filterId => provider.filters?.[filterId] !== undefined)
833+
providerIsCompatibleWithFilters(provider, filterIds) {
834+
const baseProvider = provider.searchFrom
835+
? this.providers.find((p) => p.id === provider.searchFrom) ?? provider
836+
: provider
837+
return filterIds.every((filterId) => {
838+
switch (filterId) {
839+
case 'date':
840+
return baseProvider.filters?.since !== undefined && baseProvider.filters?.until !== undefined
841+
case 'person':
842+
return baseProvider.filters?.person !== undefined
843+
default:
844+
return baseProvider.filters?.[filterId] !== undefined
845+
}
846+
})
825847
},
826848
async enableAllProviders() {
827849
this.providers.forEach(async (_, index) => {

0 commit comments

Comments
 (0)