Skip to content

Commit

Permalink
Handle when a station has no visits (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
PopFlamingo authored Apr 16, 2023
1 parent ceff407 commit 6bd071b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CTSService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,11 @@ export class CTSService {
mergedStations = true;
}

if (!station.hasVisits) {
final += "Il ne semble pas y avoir de passages à cette station actuellement.\n";
continue;
}

if (station.hasSingleTypeOfLane) {
const all = station.getMergedLanes();
final += CTSService.formatLanes(all);
Expand Down
5 changes: 5 additions & 0 deletions ConsumableSchedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export class Station {
get hasSingleTypeOfLane(): boolean {
return this.hasBusLanes !== this.hasTramLanes;
}

get hasVisits(): boolean {
return this.busLanes.some(lane => lane.directions.some(direction => direction.visits.length > 0))
|| this.tramLanes.some(lane => lane.directions.some(direction => direction.visits.length > 0));
}
}

export class Lane {
Expand Down

0 comments on commit 6bd071b

Please sign in to comment.