Skip to content

Commit

Permalink
Deduplicate search filters excluding their negated flag akin to Stigv…
Browse files Browse the repository at this point in the history
…iewer

Signed-off-by: Joyce Quach <[email protected]>
  • Loading branch information
jtquach1 committed Jan 25, 2025
1 parent 05d631a commit b399321
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions apps/frontend/src/store/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,16 @@ class Search extends VuexModule {
}

// If coming from a category filter, else a quick filter
const categoryFilter = this.categoryToFilterMapping.get(
searchPayload.field
);
const searchPayloadField =
searchPayload.field === '' ? 'keywords' : searchPayload.field;
const categoryFilter = this.categoryToFilterMapping.get(searchPayloadField);
const usingCategoryFilter = !!categoryFilter;
const isDuplicateCategoryFilter = this.parsedSearchResult
.getConditionArray()
.find(
(value) =>
value.keyword === categoryFilter &&
value.value === searchPayload.value &&
value.negated === searchPayload.negated
value.value === searchPayload.value
);

if (usingCategoryFilter && !isDuplicateCategoryFilter) {
Expand All @@ -181,14 +180,13 @@ class Search extends VuexModule {
.getConditionArray()
.find(
(value) =>
value.keyword === searchPayload.field &&
value.value === searchPayload.value &&
value.negated === searchPayload.negated
value.keyword === searchPayloadField &&
value.value === searchPayload.value
);

if (usingQuickFilter && !isDuplicateQuickFilter) {
this.parsedSearchResult.addEntry(
searchPayload.field,
searchPayloadField,
searchPayload.value,
searchPayload.negated
);
Expand Down

0 comments on commit b399321

Please sign in to comment.