diff --git a/functions/api/get-services.ts b/functions/api/get-services.ts index f84663f9a..d5ee35ab3 100644 --- a/functions/api/get-services.ts +++ b/functions/api/get-services.ts @@ -128,7 +128,7 @@ export interface TimingLocation { lateness: any associations: Association[] | null adhocAlerts: any - activities?: string + activities?: string[] } export enum AssociationCategory { @@ -284,9 +284,14 @@ async function processService(service: TrainService): Promise { } } - location.activities = serviceData?.locations.find(l => { + const activities = serviceData?.locations.find(l => { return l.tiploc === location.tiploc && (l.sta === location.sta || l.std === location.std) - })?.activities + })?.activities as string | undefined + + // Split into array with groups of two chars + if (activities) { + location.activities = (activities?.match(/.{2}/g) || []).map(a => a.trim()) + } } } diff --git a/src/components/AmeyLiveTrainAnnouncements.tsx b/src/components/AmeyLiveTrainAnnouncements.tsx index d81897546..2268aeefd 100644 --- a/src/components/AmeyLiveTrainAnnouncements.tsx +++ b/src/components/AmeyLiveTrainAnnouncements.tsx @@ -64,7 +64,7 @@ function getCallingPoints( if (s.isCancelled || s.isOperational || s.isPass) return false if (!stations.includes(s.crs)) return false // Ignore pick-up only - if (s.activities === 'U') return false + if (s.activities?.includes('U')) return false return true }) @@ -94,7 +94,7 @@ function getCallingPoints( crsCode: getStation(p), name: '', randomId: '', - requestStop: p.activities === 'R', + requestStop: p.activities?.includes('R'), } p.associations @@ -111,7 +111,7 @@ function getCallingPoints( if (!stations.includes(s.crs)) return false return true }) - .map(l => ({ crsCode: l.crs!!, name: l.locationName, randomId: '', requestStop: p.activities === 'R' })) + .map(l => ({ crsCode: l.crs!!, name: l.locationName, randomId: '', requestStop: p.activities?.includes('R') })) }) if (i === callingPoints.length - 1 && p.associations?.some(a => a.category === AssociationCategory.LinkedTo && a.trainid === '0B00')) { @@ -141,7 +141,7 @@ function getCallingPoints( crsCode: getStation(p), name: '', randomId: '', - requestStop: p.activities === 'R', + requestStop: p.activities?.includes('R'), } if (p.associations?.some(a => a.category === AssociationCategory.LinkedTo && a.trainid !== '0B00')) { @@ -174,7 +174,7 @@ function getCallingPoints( crsCode: getStation(p), name: '', randomId: '', - requestStop: p.activities === 'R', + requestStop: p.activities?.includes('R'), } }) .filter(Boolean) as CallingAtPoint[]