From 135c56dfd13e37dd980828b91c00f91a13b24d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartosz=20Stefa=C5=84czyk?= Date: Wed, 24 Apr 2024 09:39:56 +0200 Subject: [PATCH] remove unnecessary hook and inline task registration --- src/frontend/hooks/tracks/useTracking.ts | 41 ++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/frontend/hooks/tracks/useTracking.ts b/src/frontend/hooks/tracks/useTracking.ts index cdc5fbd9e..c84fceef7 100644 --- a/src/frontend/hooks/tracks/useTracking.ts +++ b/src/frontend/hooks/tracks/useTracking.ts @@ -20,27 +20,28 @@ export function useTracking() { const setTracking = useCurrentTrackStore(state => state.setTracking); const isTracking = useCurrentTrackStore(state => state.isTracking); - const addNewTrackLocations = useCallback( - ({data, error}: LocationCallbackInfo) => { - if (error) { - console.error('Error while processing location update callback', error); - } - if (data?.locations) { - addNewLocations( - data.locations.map(loc => ({ - latitude: loc.coords.latitude, - longitude: loc.coords.longitude, - timestamp: loc.timestamp, - })), - ); - } - }, - [addNewLocations], - ); - React.useEffect(() => { - TaskManager.defineTask(LOCATION_TASK_NAME, addNewTrackLocations); - }, [addNewTrackLocations]); + TaskManager.defineTask( + LOCATION_TASK_NAME, + ({data, error}: LocationCallbackInfo) => { + if (error) { + console.error( + 'Error while processing location update callback', + error, + ); + } + if (data?.locations) { + addNewLocations( + data.locations.map(loc => ({ + latitude: loc.coords.latitude, + longitude: loc.coords.longitude, + timestamp: loc.timestamp, + })), + ); + } + }, + ); + }, []); const startTracking = useCallback(async () => { if (isTracking) {