Skip to content

Commit 92b7e60

Browse files
committed
fix(ENG-11334): fix comments
1 parent f585214 commit 92b7e60

2 files changed

Lines changed: 10 additions & 14 deletions

File tree

src/app/shared/stores/global-search/global-search.state.spec.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,6 @@ describe('GlobalSearchState', () => {
9494
expect(mockGetFilterOptions).not.toHaveBeenCalled();
9595
});
9696

97-
it('should skip the API call for a CEDAR filter found only in extraFilters (before first fetch)', () => {
98-
const { store, mockGetFilterOptions } = setup();
99-
store.dispatch(new SetExtraFilters([CEDAR_FILTER]));
100-
// Intentionally no FetchResources — state.filters is still empty
101-
102-
store.dispatch(new LoadFilterOptions(CEDAR_FILTER.key));
103-
104-
expect(mockGetFilterOptions).not.toHaveBeenCalled();
105-
});
106-
10797
it('should set isLoaded to true for a CEDAR filter when short-circuiting', () => {
10898
const { store } = setup();
10999

src/app/shared/stores/global-search/global-search.state.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,17 @@ export class GlobalSearchState {
293293
const { extraFilters } = ctx.getState();
294294
const apiFilterKeys = new Set(response.filters.map((f) => f.key));
295295

296+
const extraByKey = new Map(extraFilters.map((ef) => [ef.key, ef]));
297+
296298
const merged = response.filters.map((apiFilter) => {
297-
const cedarExtra = extraFilters.find((ef) => ef.key === apiFilter.key);
298-
return cedarExtra?.cedarPropertyIri
299-
? { ...apiFilter, cedarPropertyIri: cedarExtra.cedarPropertyIri, options: cedarExtra.options }
300-
: apiFilter;
299+
const cedarExtra = extraByKey.get(apiFilter.key);
300+
if (!cedarExtra) return apiFilter;
301+
302+
return {
303+
...apiFilter,
304+
cedarPropertyIri: cedarExtra.cedarPropertyIri,
305+
...(cedarExtra.options !== undefined && { options: cedarExtra.options }),
306+
};
301307
});
302308
const extraFiltersNotInApi = extraFilters.filter((ef) => !apiFilterKeys.has(ef.key));
303309

0 commit comments

Comments
 (0)