From 9a1d058ad9877d29cf15fbed6ac7b7c08ef704e9 Mon Sep 17 00:00:00 2001 From: Tobias Kohr Date: Wed, 21 Feb 2024 09:54:57 +0100 Subject: [PATCH] review(effects): address comments --- .../search/src/lib/state/effects.spec.ts | 4 +-- libs/feature/search/src/lib/state/effects.ts | 25 +++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/libs/feature/search/src/lib/state/effects.spec.ts b/libs/feature/search/src/lib/state/effects.spec.ts index 98d60c2e54..d7c49215bc 100644 --- a/libs/feature/search/src/lib/state/effects.spec.ts +++ b/libs/feature/search/src/lib/state/effects.spec.ts @@ -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, }) ) }) diff --git a/libs/feature/search/src/lib/state/effects.ts b/libs/feature/search/src/lib/state/effects.ts index 8735ea60cc..6b5ae76be1 100644 --- a/libs/feature/search/src/lib/state/effects.ts +++ b/libs/feature/search/src/lib/state/effects.ts @@ -130,22 +130,21 @@ export class SearchEffects { } 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]), + map((geom) => [state, favorites, geom ?? null]), catchError((e) => { return of([state, favorites, null]) })