diff --git a/app-src/scripts/main/global-services/notifier-s.js b/app-src/scripts/main/global-services/notifier-s.js index 47df351c4a..f04390482a 100644 --- a/app-src/scripts/main/global-services/notifier-s.js +++ b/app-src/scripts/main/global-services/notifier-s.js @@ -6,7 +6,7 @@ * Service in the superProductivity. */ -(function () { +(function() { 'use strict'; angular @@ -21,18 +21,24 @@ Notification.requestPermission(); } - return function (notification) { + return function(notification) { if (IS_ELECTRON) { // send to electron window.ipcRenderer.send(IPC_NOTIFIER_EV, notification); } else if (Notification && Notification.permission === 'granted') { - new Notification(notification.title, { + const notificationInstance = new Notification(notification.title, { icon: notification.icon || 'img/icon_128x128-with-pad.png', body: notification.message }); + + notificationInstance.onclick = () => { + notificationInstance.close(); + }; + + setTimeout(() => { + notificationInstance.close(); + }, notification.time || 10000); } }; - } - })(); diff --git a/app-src/scripts/pomodoro-button/pomodoro-button-s.js b/app-src/scripts/pomodoro-button/pomodoro-button-s.js index 61122fff64..140a62e90b 100644 --- a/app-src/scripts/pomodoro-button/pomodoro-button-s.js +++ b/app-src/scripts/pomodoro-button/pomodoro-button-s.js @@ -18,7 +18,7 @@ class PomodoroButton { /* @ngInject */ - constructor($rootScope, $interval, $q, Dialogs, Tasks, SimpleToast, LS_DEFAULTS, EV, IS_ELECTRON) { + constructor($rootScope, $interval, $q, Dialogs, Tasks, SimpleToast, LS_DEFAULTS, EV, IS_ELECTRON, Notifier) { this.LS_DEFAULTS = LS_DEFAULTS; this.IS_ELECTRON = IS_ELECTRON; this.EV = EV; @@ -28,6 +28,7 @@ this.Dialogs = Dialogs; this.SimpleToast = SimpleToast; this.Tasks = Tasks; + this.Notifier = Notifier; this.initListeners(); @@ -137,6 +138,10 @@ this.playSessionDoneSound(); this.data.isOnBreak = !this.data.isOnBreak; if (this.data.isOnBreak) { + this.Notifier({ + title: 'Pomodoro break #' + this.data.currentCycle + ' started.', + }); + this.dialog = this.Dialogs('POMODORO_BREAK', { pomodoroData: this.data, pomodoroConfig: this.config @@ -153,7 +158,12 @@ } } else { this.data.currentCycle++; - this.selectTask(); + this.selectTask() + .then(() => { + this.Notifier({ + title: 'Pomodoro session #' + this.data.currentCycle + ' started.', + }); + }); } this.setSessionTimerTime();