Clean up event types to make them more human friendly

This commit is contained in:
Robbie Trencheny 2016-08-17 14:39:53 -07:00
parent 5bb5d6800c
commit 8439fafb7f

View File

@ -6,7 +6,7 @@ self.addEventListener("push", function(event) {
self.registration.showNotification(data.title, data) self.registration.showNotification(data.title, data)
.then(function(notification){ .then(function(notification){
firePushCallback({ firePushCallback({
type: "push", type: "received",
tag: data.tag, tag: data.tag,
data: data.data data: data.data
}, data.data.jwt); }, data.data.jwt);
@ -17,7 +17,7 @@ self.addEventListener("push", function(event) {
self.addEventListener('notificationclick', function(event) { self.addEventListener('notificationclick', function(event) {
var url; var url;
notificationEventCallback(event); notificationEventCallback('clicked', event);
event.notification.close(); event.notification.close();
@ -50,15 +50,15 @@ self.addEventListener('notificationclick', function(event) {
); );
}); });
self.addEventListener('notificationclose', function(event) { self.addEventListener('notificationclose', function(event) {
notificationEventCallback(event); notificationEventCallback('closed', event);
}); });
function notificationEventCallback(event){ function notificationEventCallback(event_type, event){
firePushCallback({ firePushCallback({
action: event.action, action: event.action,
data: event.notification.data, data: event.notification.data,
tag: event.notification.tag, tag: event.notification.tag,
type: event.type.replace("notification", "") type: event_type
}, event.notification.data.jwt); }, event.notification.data.jwt);
} }
function firePushCallback(payload, jwt){ function firePushCallback(payload, jwt){