From 84d3c377b4c75ede01a990c0fab5606f70ce432c Mon Sep 17 00:00:00 2001 From: Carmine D'Amico Date: Sun, 5 Jun 2016 12:50:15 +0200 Subject: [PATCH] first implementation for flash notification and settings to configure these --- src/browser/settings.jsx | 50 +++++++++++++++++++++++++++++++++++++++- src/common/settings.js | 5 +++- src/main.js | 5 ++++ 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/browser/settings.jsx b/src/browser/settings.jsx index 224d9601..a5efcd97 100644 --- a/src/browser/settings.jsx +++ b/src/browser/settings.jsx @@ -49,7 +49,10 @@ var SettingsPage = React.createClass({ showTrayIcon: this.state.showTrayIcon, trayIconTheme: this.state.trayIconTheme, disablewebsecurity: this.state.disablewebsecurity, - version: settings.version + version: settings.version, + notifications: { + flashWindow: this.state.notifications.flashWindow + } }; settings.writeFileSync(this.props.configFile, config); if (process.platform === 'win32' || process.platform === 'linux') { @@ -96,6 +99,13 @@ var SettingsPage = React.createClass({ }); } }, + handleFlashWindowSetting: function(item) { + this.setState({ + notifications: { + flashWindow: item.state + } + }); + }, render: function() { var buttonStyle = { @@ -136,6 +146,40 @@ var SettingsPage = React.createClass({ ) : null; + var notificationSettings = [ + { + label: 'Never', + state: 0 + }, + { + label: 'Only when idle (after 10 seconds)', + state: 1 + }, + { + label: 'Always', + state: 2 + } + ]; + + var that = this; + var notificationElements = notificationSettings.map(function(item) { + var boundClick = that.handleFlashWindowSetting.bind(that, item); + return ( + + ); + }); + + var notifications = ( + + +

Notifications

+ { notificationElements } + +
+ ) + return ( @@ -150,6 +194,10 @@ var SettingsPage = React.createClass({ { teams_row } { options_row } + { notifications } +
+
+
diff --git a/src/common/settings.js b/src/common/settings.js index d9561194..093dcf8f 100644 --- a/src/common/settings.js +++ b/src/common/settings.js @@ -26,7 +26,10 @@ var loadDefault = function(version) { showTrayIcon: false, trayIconTheme: '', disablewebsecurity: true, - version: 1 + version: 1, + notifications: { + flashWindow: 0 // 0 = flash never, 1 = only when idle (after 10 seconds), 2 = always + } }; } } diff --git a/src/main.js b/src/main.js index baa80e49..ef3a7792 100644 --- a/src/main.js +++ b/src/main.js @@ -189,6 +189,10 @@ app.on('ready', function() { title: arg.title, content: arg.options.body }); + + if (config.notifications.flashWindow == 2) { + mainWindow.flashFrame(true); + } }); // Set overlay icon from dataURL @@ -209,6 +213,7 @@ app.on('ready', function() { } else { trayIcon.setImage(trayImages.normal); + mainWindow.flashFrame(false); trayIcon.setToolTip(app.getName()); } });