mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 13:14:58 +08:00
Merge pull request #194 from matrix-org/audio_notifications
Make audio notifications work
This commit is contained in:
commit
052925d95b
@ -35,7 +35,7 @@ var Notifier = {
|
||||
return TextForEvent.textForEvent(ev);
|
||||
},
|
||||
|
||||
displayNotification: function(ev, room) {
|
||||
displayNotification: function(ev, room, actions) {
|
||||
if (!global.Notification || global.Notification.permission != 'granted') {
|
||||
return;
|
||||
}
|
||||
@ -83,12 +83,20 @@ var Notifier = {
|
||||
});
|
||||
global.focus();
|
||||
};
|
||||
|
||||
/*var audioClip;
|
||||
|
||||
if (audioNotification) {
|
||||
audioClip = playAudio(audioNotification);
|
||||
}*/
|
||||
|
||||
var playAudio = function() {
|
||||
var e = document.getElementById("messageAudio");
|
||||
if (e) {
|
||||
e.load();
|
||||
e.play();
|
||||
return e;
|
||||
}
|
||||
};
|
||||
|
||||
var audioClip;
|
||||
if (actions.tweaks.sound) {
|
||||
audioClip = playAudio();
|
||||
}
|
||||
|
||||
global.setTimeout(function() {
|
||||
notification.close();
|
||||
@ -198,7 +206,7 @@ var Notifier = {
|
||||
|
||||
var actions = MatrixClientPeg.get().getPushActionsForEvent(ev);
|
||||
if (actions && actions.notify) {
|
||||
this.displayNotification(ev, room);
|
||||
this.displayNotification(ev, room, actions);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -207,4 +215,4 @@ if (!global.mxNotifier) {
|
||||
global.mxNotifier = Notifier;
|
||||
}
|
||||
|
||||
module.exports = global.mxNotifier;
|
||||
module.exports = global.mxNotifier;
|
||||
|
Loading…
Reference in New Issue
Block a user