about summary refs log tree commit diff
path: root/app/javascript/mastodon/service_worker/web_push_notifications.js
diff options
context:
space:
mode:
authorYamagishi Kazutoshi <ykzts@desire.sh>2022-08-26 03:10:01 +0900
committerGitHub <noreply@github.com>2022-08-25 20:10:01 +0200
commit81e1cc5fece9a431c28ca648c2dd4b1b5f643f13 (patch)
tree0ab25ce1a64ab1f40c726b907fca8f71b86f7774 /app/javascript/mastodon/service_worker/web_push_notifications.js
parent55bef1e34fc3b07ed7f762d565a161e74e128016 (diff)
Replace to `workbox-webpack-plugin` from `offline-plugin` (#18409)
Diffstat (limited to 'app/javascript/mastodon/service_worker/web_push_notifications.js')
-rw-r--r--app/javascript/mastodon/service_worker/web_push_notifications.js7
1 files changed, 2 insertions, 5 deletions
diff --git a/app/javascript/mastodon/service_worker/web_push_notifications.js b/app/javascript/mastodon/service_worker/web_push_notifications.js
index 48a2be7e7..9b75e9b9d 100644
--- a/app/javascript/mastodon/service_worker/web_push_notifications.js
+++ b/app/javascript/mastodon/service_worker/web_push_notifications.js
@@ -75,7 +75,7 @@ const formatMessage = (messageId, locale, values = {}) =>
 const htmlToPlainText = html =>
   unescape(html.replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n').replace(/<[^>]*>/g, ''));
 
-const handlePush = (event) => {
+export const handlePush = (event) => {
   const { access_token, notification_id, preferred_locale, title, body, icon } = event.data.json();
 
   // Placeholder until more information can be loaded
@@ -189,7 +189,7 @@ const openUrl = url =>
     return self.clients.openWindow(url);
   });
 
-const handleNotificationClick = (event) => {
+export const handleNotificationClick = (event) => {
   const reactToNotificationClick = new Promise((resolve, reject) => {
     if (event.action) {
       if (event.action === 'expand') {
@@ -211,6 +211,3 @@ const handleNotificationClick = (event) => {
 
   event.waitUntil(reactToNotificationClick);
 };
-
-self.addEventListener('push', handlePush);
-self.addEventListener('notificationclick', handleNotificationClick);