diff options
author | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-01 14:16:35 -0600 |
---|---|---|
committer | Logan Hunt <loganhunt@simponic.xyz> | 2022-04-01 14:16:35 -0600 |
commit | 1108970a6aeb98a2f113383c6437dd4d862dae10 (patch) | |
tree | 30c5d3f60746d92fe37a3a8dd8f0c4c4cc5e052d /client/components | |
parent | f62854ebaa689c4bf434f213f1f610a1779f8696 (diff) | |
download | locchat-1108970a6aeb98a2f113383c6437dd4d862dae10.tar.gz locchat-1108970a6aeb98a2f113383c6437dd4d862dae10.zip |
Updates
Diffstat (limited to 'client/components')
-rw-r--r-- | client/components/home/_home.jsx | 4 | ||||
-rw-r--r-- | client/components/map/chat_room_geoman.jsx | 16 |
2 files changed, 7 insertions, 13 deletions
diff --git a/client/components/home/_home.jsx b/client/components/home/_home.jsx index 213d43e..a31fd63 100644 --- a/client/components/home/_home.jsx +++ b/client/components/home/_home.jsx @@ -28,8 +28,8 @@ export const Home = () => { }; const joinRoom = async (id, userPosition) => { - const res = await api.get(`/chat_rooms/${id}/joinable?lat=${userPosition.lat}&lng=${userPosition.lng}`); - if (res) { + const joinable = await api.get(`/chat_rooms/${id}/joinable?lat=${userPosition.lat}&lng=${userPosition.lng}`); + if (joinable) { navigate(`/rooms/${id}`); } }; diff --git a/client/components/map/chat_room_geoman.jsx b/client/components/map/chat_room_geoman.jsx index c4655ee..a39b45a 100644 --- a/client/components/map/chat_room_geoman.jsx +++ b/client/components/map/chat_room_geoman.jsx @@ -53,17 +53,12 @@ export const Geoman = ({ user, userPos, joinRoom }) => { let dontRedirect = true; const circleAndMarkerFromChatroom = (chatRoom) => { const circle = new L.Circle(chatRoom.center, chatRoom.radius); - const marker = new L.Marker(chatRoom.center, { pmIgnore: !chatRoom.isEditable, icon }); - circle.setStyle( - chatRoom.isEditable - ? editable - : haversine(userPos, { lat: chatRoom.latitude, lng: chatRoom.longitude }) < chatRoom.radius - ? joinable - : unjoinable, - ); + const marker = new L.Marker(chatRoom.center, { pmIgnore: !chatRoom.editable, icon }); + console.log(chatRoom); + circle.setStyle(chatRoom.editable ? editable : chatRoom.joinable ? joinable : unjoinable); // We only send the id when user is in the radius marker.addEventListener('click', () => { setTimeout(() => { - if (dontRedirect) { + if (!dontRedirect) { joinRoom(chatRoom.id, userPos); return; } @@ -74,7 +69,7 @@ export const Geoman = ({ user, userPos, joinRoom }) => { marker.on('mouseover', (e) => { e.target.openPopup(); }); - if (chatRoom.isEditable) { + if (chatRoom.editable) { [circle, marker].map((x) => { x.on('pm:edit', (e) => { const coords = e.target.getLatLng(); @@ -122,7 +117,6 @@ export const Geoman = ({ user, userPos, joinRoom }) => { circleAndMarkerFromChatroom({ center: [x.latitude, x.longitude], ...x, - isEditable: user && x.userId == user.id, }); }); layersToRemove.map((x) => context.map.removeLayer(x)); |