Skip to content

Commit

Permalink
Show window even if it is hidden when notification is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
yuya-oc committed Nov 14, 2015
1 parent 6af69ff commit 184f415
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/webview/mattermost.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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();
};
});
}

0 comments on commit 184f415

Please sign in to comment.