From c9fdd3b02cce2459b3f7de7de769a9758d4cc36d Mon Sep 17 00:00:00 2001 From: Roberto Fontanarosa Date: Wed, 24 Jun 2026 13:00:05 +0200 Subject: [PATCH 1/2] Add an equals method to LocationOfInterest --- .../app/components/main-page/map/map.component.ts | 3 +-- web/src/app/models/loi.model.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/web/src/app/components/main-page/map/map.component.ts b/web/src/app/components/main-page/map/map.component.ts index 2d424609e..c119be13d 100644 --- a/web/src/app/components/main-page/map/map.component.ts +++ b/web/src/app/components/main-page/map/map.component.ts @@ -370,12 +370,11 @@ export class MapComponent implements AfterViewInit, OnChanges, OnDestroy { } } - // TODO(#1445): override equals function in LocationOfInterest after making it concrete and removing all its inherent classes private isLocationOfInterestEqual( a: LocationOfInterest, b: LocationOfInterest ): boolean { - return JSON.stringify(a) === JSON.stringify(b); + return a.equals(b); } /** diff --git a/web/src/app/models/loi.model.ts b/web/src/app/models/loi.model.ts index c44a2d12e..850473d97 100644 --- a/web/src/app/models/loi.model.ts +++ b/web/src/app/models/loi.model.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { List, Map } from 'immutable'; +import { List, Map, is } from 'immutable'; import { Geometry } from './geometry/geometry'; @@ -29,6 +29,18 @@ export class LocationOfInterest { readonly submissionCount: number = 0 ) {} + equals(other: LocationOfInterest): boolean { + return ( + this.id === other.id && + this.jobId === other.jobId && + this.customId === other.customId && + this.predefined === other.predefined && + this.submissionCount === other.submissionCount && + is(this.geometry, other.geometry) && + is(this.properties, other.properties) + ); + } + static getSmallestByArea( lois: List ): LocationOfInterest | undefined { From d17c6e8085d11b2db457a5da150c3dfb97386bd9 Mon Sep 17 00:00:00 2001 From: Roberto Fontanarosa Date: Wed, 24 Jun 2026 13:00:23 +0200 Subject: [PATCH 2/2] Improve sorting performance --- web/src/app/services/loi/loi.service.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/web/src/app/services/loi/loi.service.ts b/web/src/app/services/loi/loi.service.ts index 54d2e1ab5..4c07cfe3f 100644 --- a/web/src/app/services/loi/loi.service.ts +++ b/web/src/app/services/loi/loi.service.ts @@ -56,11 +56,13 @@ export class LocationOfInterestService { ) ), map(lois => - lois.sort((a, b) => - LocationOfInterestService.getDisplayName(a).localeCompare( - LocationOfInterestService.getDisplayName(b) - ) - ) + lois + .map(loi => ({ + loi, + name: LocationOfInterestService.getDisplayName(loi), + })) + .sort((a, b) => a.name.localeCompare(b.name)) + .map(({ loi }) => loi) ) ); }