Skip to content

Commit

Permalink
review(effects): address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohr committed Feb 21, 2024
1 parent 1510831 commit 696ca82
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions libs/feature/search/src/lib/state/effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,8 @@ describe('Effects', () => {
it('skips the geometry in the search', async () => {
await firstValueFrom(effects.loadResults$)
expect(repository.search).toHaveBeenCalledWith(
expect.not.objectContaining({
filterGeometry: { type: 'Polygon', coordinates: [[]] },
expect.objectContaining({
filterGeometry: undefined,
})
)
})
Expand Down
29 changes: 14 additions & 15 deletions libs/feature/search/src/lib/state/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,36 +126,35 @@ export class SearchEffects {
),
switchMap(([state, favorites]) => {
if (!state.params.useSpatialFilter || !this.filterGeometry$) {
return of([state, favorites, null])
return of([state, favorites, undefined])
}
return this.filterGeometry$.pipe(
tap((geom) => {
if (geom) {
try {
const trace = validGeoJson(geom, true) as string[]
if (trace?.length > 0) {
throw new Error(trace.join('\n'))
}
} catch (error) {
console.warn(
'Error while parsing the geometry filter\n',
error
)
throw new Error()
if (!geom) return
try {
const trace = validGeoJson(geom, true) as string[]
if (trace?.length > 0) {
throw new Error(trace.join('\n'))
}
} catch (error) {
console.warn(
'Error while parsing the geometry filter\n',
error
)
throw new Error()
}
}),
map((geom) => [state, favorites, geom]),
catchError((e) => {
return of([state, favorites, null])
return of([state, favorites, undefined])
})
)
}),
switchMap(
([state, favorites, geometry]: [
SearchStateSearch,
string[],
Geometry | null
Geometry | undefined
]) => {
const { currentPage, pageSize, sort } = state.params
const filters = {
Expand Down

0 comments on commit 696ca82

Please sign in to comment.