diff --git a/src/components/AmeyLiveTrainAnnouncements.tsx b/src/components/AmeyLiveTrainAnnouncements.tsx index 1fb3cdac5..69343c891 100644 --- a/src/components/AmeyLiveTrainAnnouncements.tsx +++ b/src/components/AmeyLiveTrainAnnouncements.tsx @@ -416,11 +416,11 @@ export function LiveTrainAnnouncements({ interface SetSystemForPlatformAction { platforms: string[] - systemKey: SystemKeys + systemKey: SystemKeys | null } const [systemKeyForPlatform, dispatchSystemKeyForPlatform] = useReducer( - (state: Record, action: SetSystemForPlatformAction) => { + (state: Record, action: SetSystemForPlatformAction) => { const { platforms, systemKey } = action const current = { ...state } @@ -443,7 +443,7 @@ export function LiveTrainAnnouncements({ if (typeof objData === 'object') { Object.keys(init).forEach(k => { - if (objData[k] && systemKeys.includes(objData[k])) { + if (objData[k] && (systemKeys.includes(objData[k]) || objData[k] === null)) { init[k] = objData[k] } }) @@ -1117,7 +1117,9 @@ export function LiveTrainAnnouncements({ addLog(`${services.length} services found`) console.log(`[Live Trains] ${services.length} services found`) - services = services.filter(s => s.isPassengerService) + services = services.filter( + s => s.isPassengerService && (s.platform === null || systemKeyForPlatform[getPlatformForSystemSelection(s.platform)] !== null), + ) addLog(`${services.length} of which are passenger services`) console.log(`[Live Trains] ${services.length} of which are passenger services`) @@ -1160,7 +1162,7 @@ export function LiveTrainAnnouncements({ }) if (unannouncedStandingTrain) { - const systemKey = systemKeyForPlatform[getPlatformForSystemSelection(unannouncedStandingTrain.platform)] + const systemKey = systemKeyForPlatform[getPlatformForSystemSelection(unannouncedStandingTrain.platform)]!! announceStandingTrain(unannouncedStandingTrain, abortController, systemKey) return } @@ -1197,7 +1199,7 @@ export function LiveTrainAnnouncements({ }) if (unannouncedApproachingTrain) { - const systemKey = systemKeyForPlatform[getPlatformForSystemSelection(unannouncedApproachingTrain.platform)] + const systemKey = systemKeyForPlatform[getPlatformForSystemSelection(unannouncedApproachingTrain.platform)]!! announceApproachingTrain(unannouncedApproachingTrain, abortController, systemKey) return } @@ -1247,7 +1249,7 @@ export function LiveTrainAnnouncements({ }) if (unannouncedNextTrain) { - const systemKey = systemKeyForPlatform[getPlatformForSystemSelection(unannouncedNextTrain.platform)] + const systemKey = systemKeyForPlatform[getPlatformForSystemSelection(unannouncedNextTrain.platform)]!! announceNextTrain(unannouncedNextTrain, abortController, systemKey) return } @@ -1276,7 +1278,7 @@ export function LiveTrainAnnouncements({ }) if (unannouncedDisruptedTrain) { - const systemKey = systemKeyForPlatform[getPlatformForSystemSelection(unannouncedDisruptedTrain.platform)] + const systemKey = systemKeyForPlatform[getPlatformForSystemSelection(unannouncedDisruptedTrain.platform)]!! announceDisruptedTrain(unannouncedDisruptedTrain, abortController, systemKey) return } @@ -1340,7 +1342,6 @@ export function LiveTrainAnnouncements({ return ( + +
@@ -1402,6 +1413,19 @@ export function LiveTrainAnnouncements({
Platform {platform} + + {systemKeys.map(systemKey => { return (