0
0
Fork 0

Replace to workbox-webpack-plugin from offline-plugin (#18409)

This commit is contained in:
Yamagishi Kazutoshi 2022-08-26 03:10:01 +09:00 committed by GitHub
parent 55bef1e34f
commit 81e1cc5fec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 1059 additions and 445 deletions

View file

@ -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);