Skip to content

Commit

Permalink
Guard against empty list of cars when making distance prediction.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesremuscat committed Mar 22, 2024
1 parent cdbafcd commit fe4215b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/analysis/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const Analyser = types.model({
},
views: {
get distancePrediction() {
if (!self.state.cars[0]) {
// We can't make a prediction if there are no cars!
return null;
}
const { timeElapsed, timeRemain, lapsRemain } = self.state.session;
const leaderLap = self.session.leaderLap;
const now = Date.now();
Expand Down

0 comments on commit fe4215b

Please sign in to comment.