Show window even if it is hidden when notification is clicked

This commit is contained in:
Yuya Ochiai
2015-11-14 17:34:25 +09:00
parent 6af69ff808
commit 184f415e95

View File

@@ -7,6 +7,7 @@ ipc.on('retrieveUnreadCount', function() {
ipc.sendToHost('retrieveUnreadCount', unreadCount);
});
// Show balloon when notified.
if (process.platform === 'win32') {
Notification = function(title, options) {
ipc.send('notified', {
@@ -19,3 +20,24 @@ if (process.platform === 'win32') {
};
Notification.prototype.close = function() {};
}
// Show window even if it is hidden when notification is clicked.
var NativeNotification = null;
if (process.platform === 'darwin') {
NativeNotification = Notification;
Notification = function(title, options) {
this.notification = new NativeNotification(title, options);
};
Notification.requestPermission = function(callback) {
callback('granted');
};
Notification.prototype.close = function() {
this.notification.close();
};
Notification.prototype.__defineSetter__('onclick', function(callback) {
this.notification.onclick = function() {
require('remote').getCurrentWindow().show();
callback();
};
});
}