Notification sound

This commit is contained in:
Philipp Heckel 2021-10-24 14:51:49 -04:00
parent 317621c696
commit 6f9fba99e6
4 changed files with 9 additions and 0 deletions

View file

@ -14,6 +14,7 @@ let topics = {};
const topicsHeader = document.getElementById("topicsHeader");
const topicsList = document.getElementById("topicsList");
const topicField = document.getElementById("topicField");
const notifySound = document.getElementById("notifySound");
const subscribeButton = document.getElementById("subscribeButton");
const subscribeForm = document.getElementById("subscribeForm");
const errorField = document.getElementById("error");
@ -59,6 +60,7 @@ const subscribeInternal = (topic, delaySec) => {
eventSource.onmessage = (e) => {
const event = JSON.parse(e.data);
new Notification(event.message);
notifySound.play();
};
topics[topic] = eventSource;
localStorage.setItem('topics', JSON.stringify(Object.keys(topics)));