Skip to content

Commit

Permalink
Merge branch 'develop' into ac/upgrade-eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 committed Jan 27, 2025
2 parents c1996e0 + 80ff18c commit 3ddc5eb
Show file tree
Hide file tree
Showing 8 changed files with 521 additions and 295 deletions.
605 changes: 338 additions & 267 deletions package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@
"@comapeo/ipc": "2.1.0",
"@expo-google-fonts/rubik": "0.2.3",
"@formatjs/intl-getcanonicallocales": "2.5.4",
"@formatjs/intl-locale": "4.2.8",
"@formatjs/intl-pluralrules": "5.4.1",
"@formatjs/intl-relativetimeformat": "11.4.8",
"@formatjs/intl-locale": "4.2.9",
"@formatjs/intl-pluralrules": "5.4.2",
"@formatjs/intl-relativetimeformat": "11.4.9",
"@gorhom/bottom-sheet": "5.0.6",
"@osm_borders/maritime_10000m": "1.1.0",
"@react-native-community/hooks": "3.0.0",
"@react-native-community/netinfo": "11.4.1",
"@react-native-picker/picker": "2.10.2",
"@react-native-picker/picker": "2.11.0",
"@react-navigation/bottom-tabs": "6.5.8",
"@react-navigation/drawer": "6.6.15",
"@react-navigation/native": "6.1.7",
"@react-navigation/native-stack": "6.9.13",
"@rnmapbox/maps": "10.1.33",
"@sentry/react-native": "5.20.0",
"@tanstack/react-query": "5.62.8",
"@turf/helpers": "7.1.0",
"@turf/random": "7.1.0",
"@sentry/react-native": "6.5.0",
"@tanstack/react-query": "5.64.2",
"@turf/helpers": "7.2.0",
"@turf/random": "7.2.0",
"@types/luxon": "3.4.2",
"assert": "2.1.0",
"buffer": "6.0.3",
Expand Down Expand Up @@ -84,36 +84,36 @@
"nanoid": "5.0.9",
"nodejs-mobile-react-native": "18.20.4",
"react": "18.2.0",
"react-hook-form": "7.54.1",
"react-intl": "7.0.4",
"react-hook-form": "7.54.2",
"react-intl": "7.1.4",
"react-native": "0.73.6",
"react-native-android-open-settings": "1.3.0",
"react-native-confirmation-code-field": "7.4.0",
"react-native-device-info": "14.0.1",
"react-native-device-info": "14.0.2",
"react-native-gesture-handler": "2.21.2",
"react-native-indicators": "0.17.0",
"react-native-linear-gradient": "2.8.3",
"react-native-mmkv": "2.12.1",
"react-native-mmkv": "2.12.2",
"react-native-progress": "5.0.1",
"react-native-reanimated": "3.16.5",
"react-native-reanimated": "3.16.7",
"react-native-restart": "0.0.27",
"react-native-safe-area-context": "4.14.0",
"react-native-scale-bar": "1.0.6",
"react-native-screens": "3.29.0",
"react-native-share": "12.0.3",
"react-native-svg": "15.10.1",
"react-native-svg": "15.11.1",
"react-native-url-polyfill": "2.0.0",
"react-native-vector-icons": "10.2.0",
"react-native-zeroconf": "0.13.8",
"readable-stream": "4.5.2",
"readable-stream": "4.7.0",
"rpc-reflector": "1.3.11",
"start-stop-state-machine": "1.2.0",
"tiny-typed-emitter": "2.1.0",
"uint8array-extras": "0.5.0",
"utm": "1.1.1",
"valibot": "0.42.1",
"validate-color": "2.2.4",
"zustand": "5.0.2"
"zustand": "5.0.3"
},
"devDependencies": {
"@babel/core": "7.25.7",
Expand All @@ -134,7 +134,7 @@
"@tanstack/eslint-plugin-query": "5.62.1",
"@testing-library/react-native": "12.4.3",
"@types/debug": "4.1.12",
"@types/geojson": "7946.0.14",
"@types/geojson": "7946.0.15",
"@types/jest": "29.5.13",
"@types/lodash.isequal": "4.5.6",
"@types/node": "20.8.4",
Expand Down
15 changes: 15 additions & 0 deletions src/frontend/hooks/server/remoteDetectionAlert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {useSuspenseQuery} from '@tanstack/react-query';
import {useActiveProject} from '../../contexts/ActiveProjectContext';

export const REMOTE_DETECTION_ALERTS_KEY = 'alerts';

export function useRemoteDetectionAlerts() {
const {projectId, projectApi} = useActiveProject();

return useSuspenseQuery({
queryFn: async () => {
return await projectApi.remoteDetectionAlert.getMany();
},
queryKey: [REMOTE_DETECTION_ALERTS_KEY, projectId],
});
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import MapboxGL from '@rnmapbox/maps';

import {useObservations} from '../../hooks/server/observations';
import {usePresetsQuery} from '../../hooks/server/presets';
import {useNavigationFromHomeTabs} from '../../hooks/useNavigationWithTypes';
import {useObservations} from '../../../hooks/server/observations';
import {usePresetsQuery} from '../../../hooks/server/presets';
import {useNavigationFromHomeTabs} from '../../../hooks/useNavigationWithTypes';
import {
createObservationMapLayerStyle,
observationsToFeatureCollection,
} from '../../lib/ObservationMapLayer.ts';
} from '../../../lib/ObservationMapLayer';

export const ObservationMapLayer = () => {
const {data: observations} = useObservations();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import React from 'react';
import MapboxGL from '@rnmapbox/maps';

import {RemoteDetectionAlert} from '@comapeo/schema';
import {FeatureCollection} from 'geojson';
import {useRemoteDetectionAlerts} from '../../../hooks/server/remoteDetectionAlert';

const LABEL_FILTER = [
'all',
[
'in',
'$type',
'Polygon',
'LineString',
'Point',
'MultiLineString',
'MultiPolygon',
'MultiPoint',
],
['has', 'alertType'],
['has', 'monthDetec'],
['has', 'yearDetec'],
];

const POINT_FILTER = ['in', '$type', 'Point', 'MultiPoint'];

const LINESTRING_FILTER = ['in', '$type', 'LineString', 'MultiLineString'];

const POLYGON_STROKE_FILTER = ['in', '$type', 'Polygon', 'MultiPolygon'];

const POLYGON_FILL_FILTER = ['in', '$type', 'Polygon', 'MultiPolygon'];

export const RemoteDetectionAlertsMapLayer = () => {
const {data: alerts} = useRemoteDetectionAlerts();

if (!alerts) {
return null;
}

return (
<MapboxGL.ShapeSource
id="alerts-source"
shape={convertRemoteDetectionAlertsToFeatures(alerts)}>
{/* Symbol Layer for Labels */}
<MapboxGL.SymbolLayer
id="comapeo-alerts-label"
filter={LABEL_FILTER}
style={{
textField: [
'concat',
['get', 'alertType'],
' (',
['get', 'monthDetec'],
'-',
['get', 'yearDetec'],
')',
],
textFont: ['Open Sans Regular'],
textOffset: [0, 0.5],
textAnchor: 'top',
textColor: '#FFFFFF',
textHaloColor: '#000000',
textHaloWidth: 1,
textHaloBlur: 1,
}}
/>

{/* Circle Layer for Points */}
<MapboxGL.CircleLayer
id="comapeo-alerts-point"
filter={POINT_FILTER}
style={{
circleRadius: 5,
circleColor: '#FF0000',
}}
/>

{/* Line Layer for LineStrings and MultiLineStrings */}
<MapboxGL.LineLayer
id="comapeo-alerts-linestring"
filter={LINESTRING_FILTER}
style={{
lineColor: '#FF0000',
lineWidth: 3,
lineOpacity: 0.8,
}}
/>

{/* Line Layer for Polygon Stroke */}
<MapboxGL.LineLayer
id="comapeo-alerts-polygon-stroke"
filter={POLYGON_STROKE_FILTER}
style={{
lineColor: '#FF0000',
lineWidth: 2,
}}
/>

{/* Fill Layer for Polygon Fill */}
<MapboxGL.FillLayer
id="comapeo-alerts-polygon-fill"
filter={POLYGON_FILL_FILTER}
style={{
fillColor: '#FF0000',
fillOpacity: 0.5,
}}
/>
</MapboxGL.ShapeSource>
);
};

function convertRemoteDetectionAlertsToFeatures(
alerts: RemoteDetectionAlert[],
): FeatureCollection {
return {
type: 'FeatureCollection',
features: alerts.map(alert => {
const dateStart = new Date(alert.detectionDateStart);
return {
type: 'Feature',
geometry: alert.geometry,
properties: {
alertType: alert.metadata.alert_type,
detectionDateStart: alert.detectionDateStart,
detectionDateEnd: alert.detectionDateEnd,
sourceId: alert.sourceId,
monthDetec: dateStart.getMonth() + 1,
yearDetec: dateStart.getFullYear(),
},
};
}),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import * as React from 'react';
import {StyleSheet} from 'react-native';

import {FeatureCollection} from 'geojson';
import {BLACK} from '../../lib/styles';
import {useTracks} from '../../hooks/server/track';
import {BLACK} from '../../../lib/styles';
import {useTracks} from '../../../hooks/server/track';
import {Track} from '@comapeo/schema';
import {OnPressEvent} from '@rnmapbox/maps/lib/typescript/src/types/OnPressEvent';
import {useNavigationFromHomeTabs} from '../../hooks/useNavigationWithTypes';
import {useNavigationFromHomeTabs} from '../../../hooks/useNavigationWithTypes';

export const TracksMapLayer = () => {
const {data: tracks} = useTracks();
Expand Down
10 changes: 6 additions & 4 deletions src/frontend/screens/MapScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../sharedComponents/icons';

import {View, StyleSheet} from 'react-native';
import {ObservationMapLayer} from './ObservationMapLayer';
import {ObservationMapLayer} from './MapLayers/ObservationMapLayer';
import {AddButton} from '../../sharedComponents/AddButton';
import {useNavigationFromHomeTabs} from '../../hooks/useNavigationWithTypes';
import {useDraftObservation} from '../../hooks/useDraftObservation';
Expand All @@ -20,9 +20,10 @@ import {GPSPermissionsModal} from './GPSPermissions/GPSPermissionsModal';
import {CurrentTrackMapLayer} from './CurrentTrack/CurrrentTrackMapLayer';
import {UserLocation} from './UserLocation';
import {useSharedLocationContext} from '../../contexts/SharedLocationContext';
import {useMapStyleJsonUrl} from '../../hooks/server/maps.ts';
import {TracksMapLayer} from './TracksMapLayer';
import {assert} from '../../lib/assert.ts';
import {useMapStyleJsonUrl} from '../../hooks/server/maps';
import {TracksMapLayer} from './MapLayers/TracksMapLayer';
import {assert} from '../../lib/assert';
import {RemoteDetectionAlertsMapLayer} from './MapLayers/RemoteDetectionAlertsLayer';

// This is the default zoom used when the map first loads, and also the zoom
// that the map will zoom to if the user clicks the "Locate" button and the
Expand Down Expand Up @@ -114,6 +115,7 @@ export const MapScreen = () => {

{isFinishedLoading && (
<>
<RemoteDetectionAlertsMapLayer />
<CurrentTrackMapLayer />
<TracksMapLayer />
<ObservationMapLayer />
Expand Down
5 changes: 5 additions & 0 deletions src/frontend/screens/Sync/ProjectSyncDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
import {ScreenContentWithDock} from '../../sharedComponents/ScreenContentWithDock';
import {HeaderText} from '../../sharedComponents/Text/HeaderText';
import {BodyText} from '../../sharedComponents/Text/BodyText';
import {REMOTE_DETECTION_ALERTS_KEY} from '../../hooks/server/remoteDetectionAlert';

const m = defineMessages({
devicesFound: {
Expand Down Expand Up @@ -156,6 +157,10 @@ export const ProjectSyncDisplay = ({
}
// TODO: All queries associated with project should be invalidated
queryClient.invalidateQueries({queryKey: [OBSERVATION_KEY, projectId]});

queryClient.invalidateQueries({
queryKey: [REMOTE_DETECTION_ALERTS_KEY, projectId],
});
});

return () => {
Expand Down

0 comments on commit 3ddc5eb

Please sign in to comment.