ctucx.git: oeffisearch

[nimlang] fast and simple tripplanner

commit 159d9f72af91154720d1bf4711b302ed4cf7f771
parent 1d5b4f2f7c6efbe6a154268ea5c84872e551296b
Author: Milan Pässler <milan@petabyte.dev>
Date: Fri, 11 Sep 2020 19:35:20 +0200

canvas: fix render where !leg.line
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/client/js/canvas.js b/client/js/canvas.js
@@ -114,7 +114,7 @@ const updateTextCache = () => {
 	for (let journey of canvasState.journeys) {
 		for (let leg of journey.legs) {
 			addTextToCache(textFor(leg), colorFor(leg, "text"));
-			if (leg.line.trainType) addTextToCache(typeTextFor(leg), "#555");
+			if (leg.line && leg.line.trainType) addTextToCache(typeTextFor(leg), "#555");
 
 			let times = [];
 			if (journey.legs.indexOf(leg) == 0) times.push(leg.departure);

@@ -223,7 +223,7 @@ const renderJourneys = () => {
 				ctx.drawImage(preRenderedText, dpr * (x + 5), Math.floor(dpr * (y + duration / 2) - preRenderedText.height / 2.3));
 				ctx.scale(dpr, dpr);
 			}
-			if (leg.line.trainType) {
+			if (leg.line && leg.line.trainType) {
 				let preRenderedTypeText = textCache[typeTextFor(leg)];
 				if ((preRenderedTypeText.height / dpr + preRenderedText.height / dpr) < duration - 5) {
 					ctx.scale(1 / dpr, 1 / dpr);