From 34c3b627a3c2d40d09f082a9bdc8c1c3a7c6df2c Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sat, 13 Jun 2015 00:04:37 +0100 Subject: [PATCH 01/12] Notifications functionality --- src/js/stores/notifications.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/js/stores/notifications.js b/src/js/stores/notifications.js index e3648a14f..540abf54a 100644 --- a/src/js/stores/notifications.js +++ b/src/js/stores/notifications.js @@ -25,23 +25,35 @@ var NotificationsStore = Reflux.createStore({ isNewNotification: function (response) { var self = this; var playSound = SettingsStore.getSettings().playSound; + var showNotification = SettingsStore.getSettings().showNotification; - if (!playSound) { return; } + if (!playSound && !showNotification) { return; } // Check if notification is already in the store. - var isNew = false; + var countNew = 0; _.map(response, function (obj) { if (!_.contains(self._previousNotifications, obj.id)) { - isNew = true; + countNew ++; } }); // Play Sound. - if (isNew) { + if (countNew > 0) { if (playSound) { var audio = new Audio('sounds/digi.wav'); audio.play(); } + if (showNotification) { + var body = (countNew = 1 ? + 'You\'ve got a new notification' : + 'You\'ve got ' + countNew + 'notifications'); + var nativeNotification = new Notification('Gitify', { + body: body + }); + nativeNotification.onclick = function () { + ipc.sendChannel('reopen-window'); + }; + } } // Now Reset the previousNotifications array. From e6c58114bfb19156e36225d59e5472098f918c0b Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sat, 13 Jun 2015 00:07:05 +0100 Subject: [PATCH 02/12] Fix tests --- src/js/stores/notifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/stores/notifications.js b/src/js/stores/notifications.js index 540abf54a..80dab5e43 100644 --- a/src/js/stores/notifications.js +++ b/src/js/stores/notifications.js @@ -46,7 +46,7 @@ var NotificationsStore = Reflux.createStore({ if (showNotification) { var body = (countNew = 1 ? 'You\'ve got a new notification' : - 'You\'ve got ' + countNew + 'notifications'); + 'You\'ve got ' + countNew + 'notifications'); var nativeNotification = new Notification('Gitify', { body: body }); From 17775b2959f19ac3a50618004e1bee1be6508823 Mon Sep 17 00:00:00 2001 From: Emmanouil Konstantinidis Date: Sat, 13 Jun 2015 00:20:48 +0100 Subject: [PATCH 03/12] Show Notifications settings --- src/js/components/settings.js | 11 ++++++++++- src/js/stores/notifications.js | 10 +++++----- src/js/stores/settings.js | 16 ++++++++++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/js/components/settings.js b/src/js/components/settings.js index bba22e1ab..8d98f0e3b 100644 --- a/src/js/components/settings.js +++ b/src/js/components/settings.js @@ -11,7 +11,8 @@ var SettingsPage = React.createClass({ var settings = SettingsStore.getSettings(); return { participating: settings.participating, - playSound: settings.playSound + playSound: settings.playSound, + showNotifications: settings.showNotifications }; }, @@ -42,6 +43,14 @@ var SettingsPage = React.createClass({ onChange={this.toggleSetting.bind(this, 'playSound')} /> +
+
Show notifications
+
+ +
+