Skip to content

Commit

Permalink
fix: repeating destination when there are cancelled calling points
Browse files Browse the repository at this point in the history
  • Loading branch information
davwheat committed Nov 5, 2023
1 parent 651e6db commit f5ed046
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/announcement-data/systems/stations/KeTechPhil.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4068,6 +4068,29 @@ function LiveTrainAnnouncements({ nextTrainHandler, system }: LiveTrainAnnouncem

const toc = processToc(firstUnannounced.operator, firstUnannounced.origin[0].crs, firstUnannounced.destination[0].crs)

const callingPoints = firstUnannounced.subsequentCallingPoints[0].callingPoint

const callingAt = (callingPoints as any[])
.map((p): any | null => {
if (p.isCancelled || p.et === 'Cancelled') return null
if (!system.stations.includes(p.crs)) return null

return p
})
.filter(x => !!x)
.map((p, i, arr): CallingAtPoint | null => {
console.log(`[${i} of ${arr.length - 1}]: ${p.crs}`)

if (i === arr.length - 1 && p.crs === firstUnannounced.destination[0].crs) return null

return {
crsCode: p.crs,
name: '',
randomId: '',
}
})
.filter(x => !!x) as CallingAtPoint[]

const options: INextTrainAnnouncementOptions = {
chime: 'four',
hour: h === '00' ? '00 - midnight' : h,
Expand All @@ -4078,21 +4101,7 @@ function LiveTrainAnnouncements({ nextTrainHandler, system }: LiveTrainAnnouncem
platform: system.platforms.includes(firstUnannounced.platform.toLowerCase()) ? firstUnannounced.platform.toLowerCase() : '1',
terminatingStationCode: firstUnannounced.destination[0].crs,
vias: [],
callingAt: firstUnannounced.subsequentCallingPoints[0].callingPoint
.map((p, i): CallingAtPoint | null => {
if (p.isCancelled || p.et === 'Cancelled') return null
if (!system.stations.includes(p.crs)) return null

if (i === firstUnannounced.subsequentCallingPoints[0].callingPoint.length - 1 && p.crs === firstUnannounced.destination[0].crs)
return null

return {
crsCode: p.crs,
name: '',
randomId: '',
}
})
.filter(x => !!x),
callingAt,
}

console.log(options)
Expand Down

0 comments on commit f5ed046

Please sign in to comment.