From 1080d02058cd67aac010322dbdb4b12867664743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Flatval?= Date: Mon, 18 Nov 2024 18:15:43 +0100 Subject: [PATCH] chore: name the save-function upsert, and take array instead of single poi --- .../concrete/pointsOfInterest/PointsOfInterestCache.ts | 2 +- .../pointsOfInterest/PointsOfInterestDomainObject.ts | 10 +++++----- .../Architecture/pointsOfInterest/PoiSharePanel.tsx | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestCache.ts b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestCache.ts index 0e3ef2dd28..f77b1917c5 100644 --- a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestCache.ts +++ b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestCache.ts @@ -63,7 +63,7 @@ export class PointsOfInterestCache { await this._poiProvider.deletePointsOfInterest(poiIds); } - public async savePointsOfInterest( + public async upsertPointsOfInterest( pois: Array> ): Promise>> { if (pois.length === 0) { diff --git a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject.ts b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject.ts index 5b2d6c38df..d0e421d3e8 100644 --- a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject.ts +++ b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject.ts @@ -134,7 +134,7 @@ export class PointsOfInterestDomainObject 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) @@ -157,10 +157,10 @@ export class PointsOfInterestDomainObject extends VisualDomainObject this.notify(Changes.selected); } - public async updatePointOfInterest( - poi: PointOfInterest - ): Promise> { - return (await this._poisCache.savePointsOfInterest([poi]))[0]; + public async updatePointsOfInterest( + pois: Array> + ): Promise>> { + return await this._poisCache.upsertPointsOfInterest(pois); } public async postCommentForPoi( diff --git a/react-components/src/components/Architecture/pointsOfInterest/PoiSharePanel.tsx b/react-components/src/components/Architecture/pointsOfInterest/PoiSharePanel.tsx index 7fbaaa25f5..b164a622ad 100644 --- a/react-components/src/components/Architecture/pointsOfInterest/PoiSharePanel.tsx +++ b/react-components/src/components/Architecture/pointsOfInterest/PoiSharePanel.tsx @@ -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); }} />