From d298ebc56d16d19fbb6121e719a3f9a88b907e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Schr=C3=B6tler?= <niklas@allround.digital> Date: Sun, 10 Dec 2023 13:06:24 +0100 Subject: [PATCH] FahrplanPanel: Now filtering stops that are 5h in the future This prevents key collisions --- src/panels/Fahrplan/FahrplanPanel.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/panels/Fahrplan/FahrplanPanel.tsx b/src/panels/Fahrplan/FahrplanPanel.tsx index fc9b7a1..e33a20c 100644 --- a/src/panels/Fahrplan/FahrplanPanel.tsx +++ b/src/panels/Fahrplan/FahrplanPanel.tsx @@ -52,6 +52,11 @@ const FahrplanPanel = (props: {definition: FahrplanPanelDefinition}) => { const delay = stringToDelay(departure.delay); const arrival = processArrival(departure.sched_date, departure.time); + // Throw away stops that are five hours in the future as keys start colliding at some point + if(arrival.getTime() >= 5 * 60 * 60 * 1000 + (new Date()).getTime()) { + continue; + } + if(existing_ind === -1) { // If it does not exist, create a new route newRoutes.push({ @@ -69,7 +74,7 @@ const FahrplanPanel = (props: {definition: FahrplanPanelDefinition}) => { countdown: parseInt(departure.countdown) }) } else { - // If it doesn't, just add a stop to the existing route + // If it does, just add a stop to the existing route newRoutes[existing_ind].stops.push({ name: departure.internal.stop, arrival, -- GitLab