From 25196eae6d9824458d9f044f660de402352624c6 Mon Sep 17 00:00:00 2001 From: HarelM Date: Thu, 13 Jun 2024 14:15:48 +0300 Subject: [PATCH] Add takeuntildestroyed --- .../src/application/components/map/traces.component.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/IsraelHiking.Web/src/application/components/map/traces.component.ts b/IsraelHiking.Web/src/application/components/map/traces.component.ts index c2e20a76a..7cf6e4b2b 100644 --- a/IsraelHiking.Web/src/application/components/map/traces.component.ts +++ b/IsraelHiking.Web/src/application/components/map/traces.component.ts @@ -1,4 +1,5 @@ import { Component } from "@angular/core"; +import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { Store } from "@ngxs/store"; import type { LngLatLike } from "maplibre-gl"; @@ -40,7 +41,7 @@ export class TracesComponent extends BaseMapComponent { type: "FeatureCollection", features: [] }; - this.store.select((state: ApplicationState) => state.tracesState.visibleTraceId).subscribe(async (id) => { + this.store.select((state: ApplicationState) => state.tracesState.visibleTraceId).pipe(takeUntilDestroyed()).subscribe(async (id) => { if (id == null) { this.clearTraceSource(); @@ -86,7 +87,7 @@ export class TracesComponent extends BaseMapComponent { this.selectedTraceStart = traceCoordinates[0]; }); - this.store.select((state: ApplicationState) => state.tracesState.missingParts).subscribe(m => { + this.store.select((state: ApplicationState) => state.tracesState.missingParts).pipe(takeUntilDestroyed()).subscribe(m => { if (m != null) { this.missingParts = structuredClone(m) as GeoJSON.FeatureCollection; } else {