Skip to content

Commit 3462f28

Browse files
committed
fix: make sure a time is always set
1 parent ec0e1de commit 3462f28

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/components/RouteSchedule/RouteSchedule.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,15 @@ function RouteStop({
162162

163163
useEffect(() => {
164164
let timeout = null;
165+
const time = trackerLayer.time || trackerLayer.engine?.time || Date.now();
165166

166-
const isStopPassed = isPassed(stop, trackerLayer.time, stations, idx);
167+
const isStopPassed = isPassed(stop, time, stations, idx);
167168
setIsStationPassed(isStopPassed);
168169

169170
// We have to refresh the stop when the state it's time_based
170171
if (stop.state === "TIME_BASED" && !isStopPassed) {
171172
timeout = setInterval(() => {
172-
setIsStationPassed(isPassed(stop, trackerLayer.time, stations, idx));
173+
setIsStationPassed(isPassed(stop, time, stations, idx));
173174
}, 20000);
174175
}
175176
return () => {

0 commit comments

Comments
 (0)