|
1 | 1 | import { useCallback, useEffect, useState } from 'react';
|
2 | 2 | import { fetchQuery } from 'react-relay';
|
3 |
| -import { checkPositioningPermission } from '../../../../action/PositionActions'; |
4 | 3 | import { legQuery } from '../../queries/LegQuery';
|
5 | 4 | import { legTime } from '../../../../util/legUtils';
|
6 | 5 | import { epochToIso } from '../../../../util/timeUtils';
|
@@ -87,19 +86,9 @@ function matchLegEnds(legs) {
|
87 | 86 | }
|
88 | 87 |
|
89 | 88 | const useRealtimeLegs = (initialLegs, mapRef, relayEnvironment) => {
|
90 |
| - const [isPositioningAllowed, setPositioningAllowed] = useState(false); |
91 | 89 | const [realTimeLegs, setRealTimeLegs] = useState(initialLegs);
|
92 | 90 | const [time, setTime] = useState(Date.now());
|
93 | 91 |
|
94 |
| - const enableMapTracking = useCallback(async () => { |
95 |
| - const permission = await checkPositioningPermission(); |
96 |
| - const isPermissionGranted = permission.state === 'granted' || true; |
97 |
| - if (isPermissionGranted) { |
98 |
| - mapRef?.enableMapTracking(); |
99 |
| - } |
100 |
| - setPositioningAllowed(isPermissionGranted); |
101 |
| - }, [mapRef]); |
102 |
| - |
103 | 92 | const queryAndMapRealtimeLegs = useCallback(
|
104 | 93 | async legs => {
|
105 | 94 | if (!legs.length) {
|
@@ -151,17 +140,16 @@ const useRealtimeLegs = (initialLegs, mapRef, relayEnvironment) => {
|
151 | 140 | }, [initialLegs, queryAndMapRealtimeLegs]);
|
152 | 141 |
|
153 | 142 | useEffect(() => {
|
154 |
| - enableMapTracking(); |
155 | 143 | fetchAndSetRealtimeLegs();
|
156 | 144 | const interval = setInterval(() => {
|
157 | 145 | fetchAndSetRealtimeLegs();
|
158 | 146 | setTime(Date.now());
|
159 | 147 | }, 10000);
|
160 | 148 |
|
161 | 149 | return () => clearInterval(interval);
|
162 |
| - }, [enableMapTracking, fetchAndSetRealtimeLegs]); |
| 150 | + }, [fetchAndSetRealtimeLegs]); |
163 | 151 |
|
164 |
| - return { realTimeLegs, time, isPositioningAllowed }; |
| 152 | + return { realTimeLegs, time }; |
165 | 153 | };
|
166 | 154 |
|
167 | 155 | export { useRealtimeLegs };
|
0 commit comments