From 0fc1a8c1f8c1d7a2781644857ebb58db489c4137 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Sun, 16 Jun 2024 08:49:36 -0700 Subject: [PATCH] [ticket/17344] Show an alert when webpush subscribing is denied PHPBB-17344 --- phpBB/assets/javascript/webpush.js | 1 + phpBB/language/en/common.php | 1 + phpBB/styles/prosilver/template/notification_dropdown.html | 2 +- phpBB/styles/prosilver/template/ucp_notifications_options.html | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/phpBB/assets/javascript/webpush.js b/phpBB/assets/javascript/webpush.js index c326fe1cff..94e542d2ae 100644 --- a/phpBB/assets/javascript/webpush.js +++ b/phpBB/assets/javascript/webpush.js @@ -150,6 +150,7 @@ function PhpbbWebpush() { // Prevent the user from clicking the subscribe button multiple times. const result = await Notification.requestPermission(); if (result === 'denied') { + phpbb.alert(subscribeButton.getAttribute('data-l-err'), subscribeButton.getAttribute('data-l-msg')); return; } diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 5933cc8f5c..43269679bf 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -515,6 +515,7 @@ $lang = array_merge($lang, array( 'NOTIFY_WEB_PUSH_ENABLE' => 'Enable Web Push notifications', 'NOTIFY_WEB_PUSH_SUBSCRIBE' => 'Subscribe', 'NOTIFY_WEB_PUSH_SUBSCRIBED'=> 'Subscribed', + 'NOTIFY_WEB_PUSH_DENIED' => 'You have denied notifications from this site. To subscribe, please allow notifications in your browser settings.', 'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.', 'NO_ACTION' => 'No action specified.', 'NO_ADMINISTRATORS' => 'There are no administrators.', diff --git a/phpBB/styles/prosilver/template/notification_dropdown.html b/phpBB/styles/prosilver/template/notification_dropdown.html index ff52543d0a..abd5c85bfd 100644 --- a/phpBB/styles/prosilver/template/notification_dropdown.html +++ b/phpBB/styles/prosilver/template/notification_dropdown.html @@ -47,7 +47,7 @@ {% if NOTIFICATIONS_WEBPUSH_ENABLE and notification_types is not defined %} {% endif %} diff --git a/phpBB/styles/prosilver/template/ucp_notifications_options.html b/phpBB/styles/prosilver/template/ucp_notifications_options.html index b3be983f16..27981581ff 100644 --- a/phpBB/styles/prosilver/template/ucp_notifications_options.html +++ b/phpBB/styles/prosilver/template/ucp_notifications_options.html @@ -10,7 +10,7 @@

{{ lang('NOTIFY_WEBPUSH_ENABLE_EXPLAIN') }}
- +