Refactor notification to simplify event handling
This commit is contained in:
@@ -97,39 +97,23 @@ function isElementVisible(elem) {
|
||||
return elem.offsetHeight !== 0;
|
||||
}
|
||||
|
||||
// On Windows 8.1 and Windows 8, a shortcut with a Application User Model ID must be installed to the Start screen.
|
||||
// In current version, use tray balloon for notification
|
||||
function isLowerThanOrEqualWindows8_1() {
|
||||
if (process.platform != 'win32') {
|
||||
return false;
|
||||
}
|
||||
var osVersion = require('../../common/osVersion');
|
||||
return (osVersion.major <= 6 && osVersion.minor <= 3);
|
||||
};
|
||||
|
||||
if (process.platform === 'win32' && isLowerThanOrEqualWindows8_1()) {
|
||||
// Show balloon when notified.
|
||||
notification.override({
|
||||
notification: function(title, options) {
|
||||
ipc.send('notified', {
|
||||
title: title,
|
||||
options: options
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
notification.override({
|
||||
// Send a notification event to the main process.
|
||||
notification: function(title, options) {
|
||||
ipc.send('notified', {
|
||||
title: title,
|
||||
options: options
|
||||
});
|
||||
},
|
||||
// Show window even if it is hidden/minimized when notification is clicked.
|
||||
notification.override({
|
||||
onclick: function() {
|
||||
if (process.platform === 'win32') {
|
||||
// show() breaks Aero Snap state.
|
||||
electron.remote.getCurrentWindow().focus();
|
||||
}
|
||||
else {
|
||||
electron.remote.getCurrentWindow().show();
|
||||
}
|
||||
ipc.sendToHost('onNotificationClick');
|
||||
onclick: function() {
|
||||
if (process.platform === 'win32') {
|
||||
// show() breaks Aero Snap state.
|
||||
electron.remote.getCurrentWindow().focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
electron.remote.getCurrentWindow().show();
|
||||
}
|
||||
ipc.sendToHost('onNotificationClick');
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user