Don't send notifications until log replay finished

This commit is contained in:
Adam Goldsmith 2023-07-14 19:46:28 -04:00
parent 6c015c322c
commit 2feabd4d87
3 changed files with 10 additions and 2 deletions

View File

@ -54,5 +54,6 @@ wss.on('connection', (ws) => {
.split('\n') .split('\n')
.filter((line) => line !== '') .filter((line) => line !== '')
.forEach((line) => ws.send(line)); .forEach((line) => ws.send(line));
ws.send("FINISHED REPLAY");
} }
}); });

View File

@ -30,13 +30,16 @@ const props = defineProps({
tactical: String, tactical: String,
timeoutLength: Number, timeoutLength: Number,
lowVoltage: Number, lowVoltage: Number,
finishedReplay: Boolean,
messages: Array, messages: Array,
now: Date, now: Date,
}); });
function notify(title, body) { function notify(title, body) {
if (props.finishedReplay) {
return new Notification(title, { body: body, requireInteraction: true }); return new Notification(title, { body: body, requireInteraction: true });
} }
}
function formatTime(time, isDuration = false) { function formatTime(time, isDuration = false) {
return new Date(time).toLocaleTimeString( return new Date(time).toLocaleTimeString(

View File

@ -27,6 +27,7 @@
:tactical="tactical" :tactical="tactical"
:lowVoltage="config.lowVoltage" :lowVoltage="config.lowVoltage"
:timeoutLength="parseDuration(config.timeoutLength)" :timeoutLength="parseDuration(config.timeoutLength)"
:finishedReplay="finishedReplay"
:messages="messagesFromStation[callsign] || []" :messages="messagesFromStation[callsign] || []"
:now="now" :now="now"
> >
@ -45,6 +46,7 @@ import config from './status_config.yaml';
const parser = new APRSParser(); const parser = new APRSParser();
let aprsStream = null; let aprsStream = null;
const finishedReplay = ref(false);
const messages = ref([]); const messages = ref([]);
const messagesFromStation = ref({}); const messagesFromStation = ref({});
const now = ref(new Date()); const now = ref(new Date());
@ -69,7 +71,9 @@ function connectToStream() {
}, 5000); }, 5000);
}; };
aprsStream.onmessage = (event) => { aprsStream.onmessage = (event) => {
if (event.data !== '') { if (event.data === 'FINISHED REPLAY') {
finishedReplay.value = true;
} else if (event.data !== '') {
handleMessage(JSON.parse(event.data)); handleMessage(JSON.parse(event.data));
} }
}; };