From f2f8296959f34d526d565e09c75a06605943c449 Mon Sep 17 00:00:00 2001 From: Spythere Date: Fri, 26 Nov 2021 09:06:29 +0100 Subject: [PATCH] =?UTF-8?q?SRJP:=20naprawiono=20wy=C5=9Bwietlanie=20si?= =?UTF-8?q?=C4=99=20szlak=C3=B3w=20w=20przypadku=20SBL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/store/index.ts b/src/store/index.ts index 03b8ed1..af7cb66 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -184,8 +184,19 @@ export const store = createStore({ if (!timetable || !trainInfo) return acc; + let lastArrivalLine = ""; + const followingStops: TrainStop[] = timetable.stopPoints.reduce((stopsAcc: TrainStop[], point) => { - if (point.pointNameRAW.toLowerCase().includes("sbl")) return stopsAcc; + if (point.pointNameRAW.toLowerCase().includes("sbl")) { + if (point.arrivalLine && !point.arrivalLine.toLocaleLowerCase().includes("sbl")) + lastArrivalLine = point.arrivalLine; + + if (point.departureLine && !point.departureLine.toLocaleLowerCase().includes("sbl")) { + stopsAcc[stopsAcc.length - 1].departureLine = point.departureLine + } + + return stopsAcc; + } const arrivalTimestamp = getTimestamp(point.arrivalTime); const arrivalRealTimestamp = getTimestamp(point.arrivalRealTime); @@ -193,6 +204,11 @@ export const store = createStore({ const departureTimestamp = getTimestamp(point.departureTime); const departureRealTimestamp = getTimestamp(point.departureRealTime); + let arrivalLine = lastArrivalLine || point.arrivalLine; + + if (lastArrivalLine != "") + lastArrivalLine = ""; + stopsAcc.push({ stopName: point.pointName, stopNameRAW: point.pointNameRAW, @@ -201,7 +217,7 @@ export const store = createStore({ mainStop: point.pointName.includes("strong"), - arrivalLine: point.arrivalLine, + arrivalLine, arrivalTimeString: timestampToString(arrivalTimestamp), arrivalTimestamp: arrivalTimestamp, arrivalRealTimeString: timestampToString(arrivalRealTimestamp),