Add notification sound for incoming messages (#267)

This commit is contained in:
Raphael 2020-02-12 18:21:35 +01:00 committed by GitHub
parent 01cec3ca91
commit e56f7bc4c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 3 deletions

Binary file not shown.

View File

@ -14,6 +14,11 @@ export const registerReactions = (stores: StoreMapping) => {
stores.wsStore.listen((message) => { stores.wsStore.listen((message) => {
stores.messagesStore.publishSingleMessage(message); stores.messagesStore.publishSingleMessage(message);
Notifications.notifyNewMessage(message); Notifications.notifyNewMessage(message);
if (message.priority >= 4) {
const src = 'static/notification.ogg';
const audio = new Audio(src);
audio.play();
}
}); });
stores.appStore.refresh(); stores.appStore.refresh();
}; };

View File

@ -19,6 +19,7 @@ export function notifyNewMessage(msg: IMessage) {
const notify = new Notify(msg.title, { const notify = new Notify(msg.title, {
body: removeMarkdown(msg.message), body: removeMarkdown(msg.message),
icon: msg.image, icon: msg.image,
silent: true,
notifyClick: closeAndFocus, notifyClick: closeAndFocus,
notifyShow: closeAfterTimeout, notifyShow: closeAfterTimeout,
}); });

View File

@ -1337,9 +1337,9 @@
integrity sha512-p/sGgiPaathCfOtqu2fx5Mu1bcjuP8ALFg4xpGgNkcin7LwRyzUKniEHBKdcE1RPsenq5JVPIpMTJSygLboygQ== integrity sha512-p/sGgiPaathCfOtqu2fx5Mu1bcjuP8ALFg4xpGgNkcin7LwRyzUKniEHBKdcE1RPsenq5JVPIpMTJSygLboygQ==
"@types/notifyjs@^3.0.0": "@types/notifyjs@^3.0.0":
version "3.0.0" version "3.0.1"
resolved "https://registry.yarnpkg.com/@types/notifyjs/-/notifyjs-3.0.0.tgz#a57126a90be2827d511d00a0615816cd5ca8a740" resolved "https://registry.yarnpkg.com/@types/notifyjs/-/notifyjs-3.0.1.tgz#eba3bec10e44309df4aba31a73bfd26a562bc755"
integrity sha512-ur3eot/3XOOYk9n/AEf904D2H7rT8FE6wWSDQVABErveLyGjBmboFAzPpThgooJ+F7mBPbTDhV+CM8sYa/TFgw== integrity sha512-yTGCyGKVMUyL36usmerZbgC6bENPXBQC3OMqhdapzCsPzFcq1g8JFFAlbMjG3lHhkiT/0GKuG9H5IE+spkXZsA==
"@types/prop-types@*": "@types/prop-types@*":
version "15.7.3" version "15.7.3"