Skip to content

Commit

Permalink
Merge pull request #58 from iMattPro/deniedsubbing
Browse files Browse the repository at this point in the history
Show message when notifications are denied
  • Loading branch information
iMattPro authored Jun 16, 2024
2 parents ad9bb9e + bc9f762 commit d602afa
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions language/en/webpushnotifications_module_ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@
'NOTIFY_WEBPUSH_UNSUBSCRIBE' => 'Unsubscribe',
'NOTIFY_WEBPUSH_SUBSCRIBED' => 'Subscribed',
'NOTIFY_WEBPUSH_DROPDOWN_TITLE' => 'Visit notifications settings to set your preferred push notifications.',
'NOTIFY_WEBPUSH_DENIED' => 'You have denied notifications from this site. To subscribe, please allow notifications in your browser settings.',
]);
2 changes: 2 additions & 0 deletions language/ru/webpushnotifications_module_ucp.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@
'NOTIFY_WEBPUSH_UNSUBSCRIBE' => 'Отписаться',
'NOTIFY_WEBPUSH_SUBSCRIBED' => 'Включено',
'NOTIFY_WEBPUSH_DROPDOWN_TITLE' => 'Посетите настройки уведомлений, чтобы установить предпочтительные push-уведомления.',
'NOTIFY_WEBPUSH_DENIED' => 'Вы запретили браузерные уведомления для даного сайта. Для того, чтобы подписаться, необходимо их разрешить в настройках браузера.',

]);
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{% if NOTIFICATIONS_WEBPUSH_ENABLE and notification_types is not defined %}
<div class="wpn-notification-dropdown-footer" title="{{ lang('NOTIFY_WEBPUSH_DROPDOWN_TITLE') }}">
<span class="ellipsis-text">{{ lang('NOTIFY_WEBPUSH_ENABLE_SHORT') ~ lang('COLON') }}</span>
<button id="subscribe_webpush" name="subscribe_webpush"><i class="icon fa-toggle-off fa-fw icon-lightgray"></i><span>{{ lang('NOTIFY_WEBPUSH_SUBSCRIBE') }}</span></button>
<button id="unsubscribe_webpush" name="unsubscribe_webpush" class="hidden"><i class="icon fa-toggle-on fa-fw icon-blue"></i><span>{{ lang('NOTIFY_WEBPUSH_SUBSCRIBED') }}</span></button>
<button id="subscribe_webpush" name="subscribe_webpush" data-l-err="{{ lang('INFORMATION') }}" data-l-msg="{{ lang('NOTIFY_WEBPUSH_DENIED') }}">
<i class="icon fa-toggle-off fa-fw icon-lightgray"></i><span>{{ lang('NOTIFY_WEBPUSH_SUBSCRIBE') }}</span>
</button>
<button id="unsubscribe_webpush" name="unsubscribe_webpush" class="hidden">
<i class="icon fa-toggle-on fa-fw icon-blue"></i><span>{{ lang('NOTIFY_WEBPUSH_SUBSCRIBED') }}</span>
</button>
</div>
{% endif %}
1 change: 1 addition & 0 deletions styles/all/template/webpush.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<dl>
<dt><label for="subscribe_webpush">{{ lang('NOTIFY_WEBPUSH_ENABLE') ~ lang('COLON') }}</label><br><span>{{ lang('NOTIFY_WEBPUSH_ENABLE_EXPLAIN') }}</span></dt>
<dd>
<input id="subscribe_webpush" type="submit" name="subscribe_webpush" value="{{ lang('NOTIFY_WEBPUSH_SUBSCRIBE') }}" class="button1 button button-form">
<input id="subscribe_webpush" type="submit" name="subscribe_webpush" value="{{ lang('NOTIFY_WEBPUSH_SUBSCRIBE') }}" class="button1 button button-form" data-l-err="{{ lang('INFORMATION') }}" data-l-msg="{{ lang('NOTIFY_WEBPUSH_DENIED') }}">
<input id="unsubscribe_webpush" type="submit" name="unsubscribe_webpush" value="{{ lang('NOTIFY_WEBPUSH_UNSUBSCRIBE') }}" class="button1 button button-form hidden">
</dd>
</dl>
Expand Down

0 comments on commit d602afa

Please sign in to comment.