diff --git a/src/components/Header/Header.jsx b/src/components/Header/Header.jsx index e4b9d5a..abc6e72 100644 --- a/src/components/Header/Header.jsx +++ b/src/components/Header/Header.jsx @@ -13,6 +13,7 @@ import { RoutesContext } from '../../hooks/getRoutes' import { NameContext } from '../../hooks/getName' import { api } from '../../services/api' import { MovingMarkerContext } from '../../hooks/getMovingMarkers' +import { GPSContext } from '../../hooks/getGPS' export function Header(props) { let navigate = useNavigate() @@ -26,6 +27,7 @@ export function Header(props) { const { setRoutes, setPlataforms, setStopId} = useContext(RoutesContext) const { setResults, results, similarNames } = useContext(NameContext) const {setTracked, setInnerCircle} = useContext(MovingMarkerContext) + const {stopFetching} = useContext(GPSContext) function clearInfo() { setTrip('') setCode("") @@ -39,6 +41,7 @@ export function Header(props) { setStopId() setSppo() setInnerCircle([]) + stopFetching() } @@ -48,6 +51,7 @@ export function Header(props) { const searchNewCode = event => { setNewCode(event.target.value) + stopFetching() setTrip('') setValue() setPlataforms([]) diff --git a/src/hooks/getMovingMarkers.jsx b/src/hooks/getMovingMarkers.jsx index 897ce65..9e401b8 100644 --- a/src/hooks/getMovingMarkers.jsx +++ b/src/hooks/getMovingMarkers.jsx @@ -101,9 +101,9 @@ export function MovingMarkerProvider({ children }) { let filteredGPS = trackedBuses.filter(item => { return routes.some(filterItem => { if (stopInfo) { - return item.linha === filterItem.trip_id.trip_short_name && item.hora[0] < 5 && item.sentido === stopInfo.direction_id && item.chegada > -1 + return item.linha === filterItem.trip_id.trip_short_name && item.hora[0] < 5 && item.sentido === stopInfo.direction_id && item.distancia > -0.100 } else { - return (item.linha === filterItem.trip_id.trip_short_name && item.hora[0] < 5 && item.chegada > -1) + return (item.linha === filterItem.trip_id.trip_short_name && item.hora[0] < 5 && item.distancia > -0.100) } }); });