Skip to content

Commit

Permalink
[frontend] merge upstream pull request
Browse files Browse the repository at this point in the history
bilde2910/Hauk#169

validate that accuracy circle is not NULL before settings its style
  • Loading branch information
warren-bank committed Feb 16, 2023
1 parent 2d9e537 commit 197399f
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions frontend/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 197399f

Please sign in to comment.