diff --git a/phpBB/styles/all/js/push_worker.js.twig b/phpBB/styles/all/js/push_worker.js.twig index 91dbf6f4ad..8d6ec3c6af 100644 --- a/phpBB/styles/all/js/push_worker.js.twig +++ b/phpBB/styles/all/js/push_worker.js.twig @@ -6,46 +6,40 @@ self.addEventListener('push', event => { return; } - let itemId = 0, - typeId = 0; + let itemId = 0; + let typeId = 0; try { const notificationData = event.data.json(); - itemId = notificationData['item_id']; - typeId = notificationData['type_id']; - } catch (e) { + itemId = notificationData.item_id; + typeId = notificationData.type_id; + } catch { self.registration.showNotification(event.data.text()); return; } const getNotificationUrl = '{{ U_WEBPUSH_GET_NOTIFICATION }}'; - let formData = new FormData(); + const formData = new FormData(); formData.append('item_id', itemId.toString(10)); formData.append('type_id', typeId.toString(10)); fetch(getNotificationUrl, { - method: 'POST', - headers: { - 'X-Requested-With': 'XMLHttpRequest' - }, - body: formData - }) - .then((response) => response.json()) - .then((response) => { - const responseBody = response.title + "\n" + response.text; + method: 'POST', + headers: { + 'X-Requested-With': 'XMLHttpRequest', + }, + body: formData, + }) + .then(response => response.json()) + .then(response => { + const responseBody = response.title + '\n' + response.text; const options = { body: responseBody, data: response, - icon: response.avatar.src - // foo: '' - //icon: image - } - self.registration.showNotification( - response.heading, - options - ); - } - ); + icon: response.avatar.src, + }; + self.registration.showNotification(response.heading, options); + }); }); /**