Merge pull request #1789 from thelounge/xpaw/notification-permission

Ask for notification permission on page load if setting is enabled
This commit is contained in:
Jérémie Astori 2017-12-01 22:42:57 -05:00 committed by GitHub
commit 8a568a3ef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,11 +132,21 @@ module.exports.initialize = () => {
.trigger("change");
$("#desktopNotifications").on("change", function() {
if ($(this).prop("checked") && Notification.permission !== "granted") {
Notification.requestPermission(updateDesktopNotificationStatus);
if ($(this).prop("checked")) {
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
// opened or when the checkbox state is changed.
// When notifications are not supported, this is never called (because