notif.js 520 B

123456789101112131415
  1. // Wait notification demand
  2. ipcRenderer.once('new-notif', (event, notification) => {
  3. // Check notification data
  4. if (notification.title && notification.body && notification.icon) {
  5. // Create notification
  6. const notif = new window.Notification(notification.title, notification);
  7. // Close notif after 2.5 sec
  8. setTimeout(() => {
  9. notif.close();
  10. ipcRenderer.send('notif-close');
  11. }, 2500)
  12. } else {
  13. ipcRenderer.send('notif-close');
  14. }
  15. });