🐛 Update map on travel's address update #388
Simon Mulquin simon@octree.ch
Wed, 13 Dec 2023 12:01:27 +0000
3 files changed,
14 insertions(+),
3 deletions(-)
M
frontend/containers/Travel/index.tsx
→
frontend/containers/Travel/index.tsx
@@ -49,6 +49,7 @@ position: 'relative',
boxShadow: focused ? `0px 0px 5px 2px ${theme.palette.primary.main}` : 'none', + scrollMarginTop: theme.spacing(2) }} id={travel.id} >
M
frontend/containers/Travel/useActions.tsx
→
frontend/containers/Travel/useActions.tsx
@@ -66,7 +66,14 @@ travelUpdate: {
...travelUpdate, }, }, - refetchQueries: ['eventByUUID'], + refetchQueries: [ + { + query: EventByUuidDocument, + variables: { + uuid: event.uuid, + }, + }, + ], }); } catch (error) { console.error(error);
M
frontend/containers/TravelColumns/index.tsx
→
frontend/containers/TravelColumns/index.tsx
@@ -70,12 +70,15 @@ );
const {latitude, longitude} = event; const showMap = latitude && longitude; + let coordsString = ''; const markers = travels.reduce((markers, travel) => { const { attributes: {meeting_latitude, meeting_longitude}, } = travel; if (meeting_latitude && meeting_longitude) { const travelObject = {id: travel.id, ...travel.attributes}; + coordsString = + coordsString + String(meeting_latitude) + String(meeting_longitude); return [ ...markers, {@@ -87,7 +90,7 @@ }
return markers; }, []); - const mapUpdateKey = `${event.uuid}.travels`; + const mapUpdateKey = `${event.uuid}.travels+${coordsString}`; if (preventUpdateKey !== mapUpdateKey) { setPreventUpdateKey(mapUpdateKey); setCenter([latitude, longitude]);@@ -95,7 +98,7 @@ setMarkers([
{ double: true, center: [latitude, longitude], - popup: <EventPopup event={event}/> + popup: <EventPopup event={event} />, }, ...markers, ]);