Make things prettier, better sound, FAQ, icon in desktop notification

This commit is contained in:
Philipp Heckel 2021-10-24 22:08:06 -04:00
parent accd36991e
commit 1321bf19dc
8 changed files with 82 additions and 29 deletions

View file

@ -59,8 +59,11 @@ const subscribeInternal = (topic, delaySec) => {
};
eventSource.onmessage = (e) => {
const event = JSON.parse(e.data);
new Notification(event.message);
notifySound.play();
new Notification(topic, {
body: event.message,
icon: '/static/img/favicon.png'
});
};
topics[topic] = eventSource;
localStorage.setItem('topics', JSON.stringify(Object.keys(topics)));
@ -80,7 +83,7 @@ const unsubscribe = (topic) => {
const test = (topic) => {
fetch(`/${topic}`, {
method: 'PUT',
body: `This is a test notification for topic ${topic}!`
body: `This is a test notification`
})
};