Skip to content

Commit 5d87722

Browse files
committed
Provide correct push worker update.
1 parent ad2ddd6 commit 5d87722

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

notification/method/webpush.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ protected function prepare_avatar($avatar)
455455

456456
$path = !empty($matches[1]) ? end($matches[1]) : $avatar;
457457

458-
return preg_replace('#^' . preg_quote($this->path_helper->get_web_root_path(), '#') . '#', $this->get_board_url(), $path, 1);
458+
return ['src' => preg_replace('#^' . preg_quote($this->path_helper->get_web_root_path(), '#') . '#', $this->get_board_url(), $path, 1)];
459459
}
460460

461461
/**

styles/all/template/push_worker.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ self.addEventListener('push', event => {
3636
const options = {
3737
body: responseBody,
3838
data: response,
39-
icon: response.avatar,
39+
icon: response.avatar.src,
4040
};
4141
self.registration.showNotification(response.heading, options);
4242
});

styles/all/template/webpush.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ function PhpbbWebpush() {
5757

5858
if ('serviceWorker' in navigator && 'PushManager' in window) {
5959
navigator.serviceWorker.register(serviceWorkerUrl)
60-
.then(() => {
60+
.then((registration) => {
6161
subscribeButton.addEventListener('click', subscribeButtonHandler);
6262
unsubscribeButton.addEventListener('click', unsubscribeButtonHandler);
63+
registration.update();
6364

6465
updateButtonState();
6566
})

0 commit comments

Comments
 (0)