diff --git a/client.js b/client.js
index 1f3cc12..e482006 100644
--- a/client.js
+++ b/client.js
@@ -95,7 +95,8 @@ function redrawTable() {
else {
let station = stations[callsign];
- let nowDelta = new Date(new Date() - station.lastHeard);
+ let lastHeard = new Date(station.lastHeard);
+ let nowDelta = new Date(new Date() - lastHeard);
// TODO: should be set by same thing that sends alert
if (nowDelta.getTime() > timeoutLength) {
@@ -105,7 +106,7 @@ function redrawTable() {
tr.classList.add('lowVoltage');
}
tr.innerHTML +=
- `
${station.lastHeard.toLocaleTimeString('en-GB')} | ` +
+ `${lastHeard.toLocaleTimeString('en-GB')} | ` +
`${nowDelta.toLocaleTimeString('en-GB', {timeZone: "UTC"})} | ` +
`${station.lastVoltage||''} | ` +
`${station.lastTemperature||''} | `;
@@ -119,7 +120,7 @@ function notify(title, body) {
function alertNotHeard(callsign) {
notify(`${getTactical(callsign)} has not been heard for ${prettyDuration(timeoutLength)}!`,
- `Last Heard: ${stations[callsign].lastHeard.toLocaleTimeString('en-GB')}`);
+ `Last Heard: ${new Date(stations[callsign].lastHeard).toLocaleTimeString('en-GB')}`);
}
function alertVoltage(callsign) {
@@ -144,7 +145,7 @@ function handleMessage(message) {
window.clearTimeout(stations[callsign].timeout);
}
- stations[callsign].lastHeard = date;
+ stations[callsign].lastHeard = date.getTime();
stations[callsign].delta = date - stations[callsign].lastHeard;
stations[callsign].timeout = window.setTimeout(
alertNotHeard, timeoutLength, callsign);