Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions web/src/app/components/main-page/map/map.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
14 changes: 13 additions & 1 deletion web/src/app/models/loi.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { List, Map } from 'immutable';
import { List, Map, is } from 'immutable';

import { Geometry } from './geometry/geometry';

Expand All @@ -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>
): LocationOfInterest | undefined {
Expand Down
12 changes: 7 additions & 5 deletions web/src/app/services/loi/loi.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
);
}
Expand Down
Loading