Skip to content

Commit

Permalink
chore: name the save-function upsert, and take array instead of singl…
Browse files Browse the repository at this point in the history
…e poi
  • Loading branch information
haakonflatval-cognite committed Nov 18, 2024
1 parent f897ff7 commit 1080d02
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class PointsOfInterestCache<PoiId> {
await this._poiProvider.deletePointsOfInterest(poiIds);
}

public async savePointsOfInterest(
public async upsertPointsOfInterest(
pois: Array<PointsOfInterestInstance<PoiId>>
): Promise<Array<PointsOfInterestInstance<PoiId>>> {
if (pois.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class PointsOfInterestDomainObject<PoiIdType> extends VisualDomainObject
const poisToCreate = this._pointsOfInterest.filter(
(obs) => obs.status === PointsOfInterestStatus.PendingCreation
);
const newPointsOfInterest = await this._poisCache.savePointsOfInterest(poisToCreate);
const newPointsOfInterest = await this._poisCache.upsertPointsOfInterest(poisToCreate);

this._pointsOfInterest = notToRemove
.filter((poi) => poi.status === PointsOfInterestStatus.Default)
Expand All @@ -157,10 +157,10 @@ export class PointsOfInterestDomainObject<PoiIdType> extends VisualDomainObject
this.notify(Changes.selected);
}

public async updatePointOfInterest(
poi: PointOfInterest<PoiIdType>
): Promise<PointsOfInterestInstance<PoiIdType>> {
return (await this._poisCache.savePointsOfInterest([poi]))[0];
public async updatePointsOfInterest(
pois: Array<PointOfInterest<PoiIdType>>
): Promise<Array<PointsOfInterestInstance<PoiIdType>>> {
return await this._poisCache.upsertPointsOfInterest(pois);
}

public async postCommentForPoi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const PoiVisibilityInfobox = ({
checked={markedPublic}
onChange={(_: InputEvent, checked: boolean) => {
selectedPointOfInterest.properties.visibility = checked ? 'PUBLIC' : 'PRIVATE';
void poiDomainObject.updatePointOfInterest(selectedPointOfInterest);
void poiDomainObject.updatePointsOfInterest([selectedPointOfInterest]);
poiDomainObject.notify(Changes.geometry);
}}
/>
Expand Down

0 comments on commit 1080d02

Please sign in to comment.