Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
♻️ Fix notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesprague committed Jun 22, 2020
1 parent 054b0ee commit f7940fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/js/extension.js
Expand Up @@ -88,13 +88,13 @@ const initExtension = () => {
const statusText = document.querySelector('.delivery-status-text');
appConfig.statusStrings.delivered.forEach(statusString => {
if (deliveryStatus.includes(statusString)) {
sendDeliveryNotiication();
statusImage.src = appConfig.favicons.delivered;
statusText.classList.add('delivered');
statusText.textContent = 'Delivered';
clearInterval(clockTimerHandle);
document.querySelector('#extension-overlay h3').remove();
updateDelivered();
sendDeliveryNotiication();
}
});
appConfig.statusStrings.outForDelivery.forEach(statusString => {
Expand Down Expand Up @@ -130,6 +130,9 @@ const initExtension = () => {
// - [ ] release in mozilla add-ons

document.onreadystatechange = () => {
Notification.requestPermission().then((result) => {
console.log(result);
});
if (document.readyState === 'complete') {
initExtension();
}
Expand Down
13 changes: 6 additions & 7 deletions src/js/modules/helpers.js
Expand Up @@ -5,6 +5,7 @@ export const appConfig = {
delivered: 'https://raw.githubusercontent.com/mikesprague/delivery-status/master/src/images/delivered.png',
inTransit: 'https://raw.githubusercontent.com/mikesprague/delivery-status/master/src/images/in-transit.png',
outForDelivery: 'https://raw.githubusercontent.com/mikesprague/delivery-status/master/src/images/out-for-delivery.png',
main: 'https://raw.githubusercontent.com/mikesprague/delivery-status/master/src/images/delivery-status-icon.png',
},
statusStrings: {
delivered: ['delivered'],
Expand Down Expand Up @@ -54,15 +55,13 @@ export function currentService() {
}

export function sendDeliveryNotiication () {
const notifTitle = 'Delivery Notification';
const notifBody = 'Your package has been delivered.';
const notifImg = '/images/delivery-status-icon.png';
const title = 'Delivery Status Extension';
const body = 'Your package has been delivered.';
const options = {
body: notifBody,
icon: notifImg
body,
icon: appConfig.favicons.main,
};
const notif = new Notification(notifTitle, options);
return notif;
new Notification(title, options);
}

export function initOverlay() {
Expand Down

0 comments on commit f7940fc

Please sign in to comment.