mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 04:23:13 +00:00
Ask for notification permission on page load if setting is enabled
This commit is contained in:
parent
a469f22699
commit
6aff2657e9
1 changed files with 12 additions and 2 deletions
|
@ -132,11 +132,21 @@ module.exports.initialize = () => {
|
||||||
.trigger("change");
|
.trigger("change");
|
||||||
|
|
||||||
$("#desktopNotifications").on("change", function() {
|
$("#desktopNotifications").on("change", function() {
|
||||||
if ($(this).prop("checked") && Notification.permission !== "granted") {
|
if ($(this).prop("checked")) {
|
||||||
Notification.requestPermission(updateDesktopNotificationStatus);
|
requestPermissionIfNeeded();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var requestPermissionIfNeeded = function() {
|
||||||
|
if (Notification.permission !== "granted") {
|
||||||
|
Notification.requestPermission(updateDesktopNotificationStatus);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (options.desktopNotifications) {
|
||||||
|
requestPermissionIfNeeded();
|
||||||
|
}
|
||||||
|
|
||||||
// Updates the checkbox and warning in settings when the Settings page is
|
// Updates the checkbox and warning in settings when the Settings page is
|
||||||
// opened or when the checkbox state is changed.
|
// opened or when the checkbox state is changed.
|
||||||
// When notifications are not supported, this is never called (because
|
// When notifications are not supported, this is never called (because
|
||||||
|
|
Loading…
Reference in a new issue