mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-07-30 03:00:57 +00:00
feat(pomodoro): add and improve notifications #32
This commit is contained in:
parent
c52b1f591b
commit
67e301ac6c
2 changed files with 23 additions and 7 deletions
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue