Skip to content

Commit 851787b

Browse files
committed
Another attempt at trying to figure out when and what to load
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent b799e14 commit 851787b

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

event/listener.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,8 @@ protected function add_error($event, $error_key, $param = null)
247247
*/
248248
protected function can_use_notifications()
249249
{
250-
return $this->config['allow_board_notifications']
251-
&& $this->config['wpn_webpush_enable']
252-
&& $this->user->id() !== ANONYMOUS
253-
&& (int) $this->user->data['user_type'] !== USER_IGNORE;
250+
return $this->config['wpn_webpush_enable']
251+
&& ANONYMOUS !== $this->user->id()
252+
&& USER_IGNORE !== (int) $this->user->data['user_type'];
254253
}
255254
}

notification/method/webpush.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function get_type(): string
103103
*/
104104
public function is_available(type_interface $notification_type = null): bool
105105
{
106-
return parent::is_available($notification_type) && $this->config['allow_board_notifications'] && $this->config['wpn_webpush_enable']
106+
return parent::is_available($notification_type) && $this->config['wpn_webpush_enable']
107107
&& !empty($this->config['wpn_webpush_vapid_public']) && !empty($this->config['wpn_webpush_vapid_private']);
108108
}
109109

@@ -378,7 +378,7 @@ public function get_ucp_template_data(helper $controller_helper, form_helper $fo
378378
}
379379

380380
return [
381-
'NOTIFICATIONS_WEBPUSH_ENABLE' => $this->config['wpn_webpush_dropdown_subscribe'] || stripos($this->user->page['page'], 'notification_options'),
381+
'NOTIFICATIONS_WEBPUSH_ENABLE' => ($this->config['load_notifications'] && $this->config['allow_board_notifications'] && $this->config['wpn_webpush_dropdown_subscribe']) || stripos($this->user->page['page'], 'notification_options'),
382382
'U_WEBPUSH_SUBSCRIBE' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_subscribe_controller'),
383383
'U_WEBPUSH_UNSUBSCRIBE' => $controller_helper->route('phpbb_webpushnotifications_ucp_push_unsubscribe_controller'),
384384
'VAPID_PUBLIC_KEY' => $this->config['wpn_webpush_vapid_public'],

tests/event/listener_test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ protected function setUp(): void
8282
});
8383

8484
$this->config = new \phpbb\config\config([
85+
'load_notifications' => true,
8586
'allow_board_notifications' => true,
8687
'wpn_webpush_enable' => true,
8788
]);

0 commit comments

Comments
 (0)