From 8439fafb7fc625d4827f839871295b04d6fe7293 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 17 Aug 2016 14:39:53 -0700 Subject: [PATCH] Clean up event types to make them more human friendly --- script/service-worker.js.tmpl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/script/service-worker.js.tmpl b/script/service-worker.js.tmpl index b61254ea1b..d58a4683fa 100644 --- a/script/service-worker.js.tmpl +++ b/script/service-worker.js.tmpl @@ -6,7 +6,7 @@ self.addEventListener("push", function(event) { self.registration.showNotification(data.title, data) .then(function(notification){ firePushCallback({ - type: "push", + type: "received", tag: data.tag, data: data.data }, data.data.jwt); @@ -17,7 +17,7 @@ self.addEventListener("push", function(event) { self.addEventListener('notificationclick', function(event) { var url; - notificationEventCallback(event); + notificationEventCallback('clicked', event); event.notification.close(); @@ -50,15 +50,15 @@ self.addEventListener('notificationclick', function(event) { ); }); self.addEventListener('notificationclose', function(event) { - notificationEventCallback(event); + notificationEventCallback('closed', event); }); -function notificationEventCallback(event){ +function notificationEventCallback(event_type, event){ firePushCallback({ action: event.action, data: event.notification.data, tag: event.notification.tag, - type: event.type.replace("notification", "") + type: event_type }, event.notification.data.jwt); } function firePushCallback(payload, jwt){