Merge pull request #732 from thelounge/astorije/fix-notifications
Silence failures to trigger notifications when not available
This commit is contained in:
commit
49c473c85c
@ -1011,7 +1011,11 @@ $(function() {
|
|||||||
if (msg.highlight || (options.notifyAllMessages && msg.type === "message")) {
|
if (msg.highlight || (options.notifyAllMessages && msg.type === "message")) {
|
||||||
if (!document.hasFocus() || !$(target).hasClass("active")) {
|
if (!document.hasFocus() || !$(target).hasClass("active")) {
|
||||||
if (options.notification) {
|
if (options.notification) {
|
||||||
pop.play();
|
try {
|
||||||
|
pop.play();
|
||||||
|
} catch (exception) {
|
||||||
|
// On mobile, sounds can not be played without user interaction.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
toggleNotificationMarkers(true);
|
toggleNotificationMarkers(true);
|
||||||
|
|
||||||
@ -1031,19 +1035,24 @@ $(function() {
|
|||||||
body = msg.text.replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/g, "").trim();
|
body = msg.text.replace(/\x02|\x1D|\x1F|\x16|\x0F|\x03(?:[0-9]{1,2}(?:,[0-9]{1,2})?)?/g, "").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
var notify = new Notification(title, {
|
try {
|
||||||
body: body,
|
var notify = new Notification(title, {
|
||||||
icon: "img/logo-64.png",
|
body: body,
|
||||||
tag: target
|
icon: "img/logo-64.png",
|
||||||
});
|
tag: target
|
||||||
notify.onclick = function() {
|
});
|
||||||
window.focus();
|
notify.onclick = function() {
|
||||||
button.click();
|
window.focus();
|
||||||
this.close();
|
button.click();
|
||||||
};
|
this.close();
|
||||||
window.setTimeout(function() {
|
};
|
||||||
notify.close();
|
window.setTimeout(function() {
|
||||||
}, 5 * 1000);
|
notify.close();
|
||||||
|
}, 5 * 1000);
|
||||||
|
} catch (exception) {
|
||||||
|
// `new Notification(...)` is not supported and should be silenced.
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user