From 197399f23e8a08315851487ad44be7146efc95cc Mon Sep 17 00:00:00 2001 From: Warren R Bank Date: Thu, 16 Feb 2023 05:02:40 -0800 Subject: [PATCH] [frontend] merge upstream pull request https://github.com/bilde2910/Hauk/pull/169 validate that accuracy circle is not NULL before settings its style --- frontend/main.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index 6a96c56..05573e1 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -872,19 +872,13 @@ function processUpdate(data, init) { } eLastSeen.textContent = unit.split("{{time}}").join(time); } - shares[user].circle.setStyle({ - fillColor: STATE_DEAD_COLOR, - color: STATE_DEAD_COLOR - }) + setAccuracyCircleColor(shares[user].circle, STATE_DEAD_COLOR); } else { eArrow.className = eArrow.className.split("dead").join(shares[user].state); if (eLabel !== null) eLabel.className = shares[user].state; var iconColor = STATE_LIVE_COLOR; if (shares[user].state == "rough") iconColor = STATE_ROUGH_COLOR; - shares[user].circle.setStyle({ - fillColor: iconColor, - color: iconColor - }); + setAccuracyCircleColor(shares[user].circle, iconColor); } } } @@ -918,6 +912,15 @@ function getTrackColor(user) { return trackColor; } +function setAccuracyCircleColor(circle, color) { + if( circle ) { + circle.setStyle({ + fillColor: color, + color: color + }); + } +} + // Calculates the distance between two points on a sphere using the Haversine // algorithm. function distance(from, to) {