Set Application User Model ID and use Electron's notification

This commit is contained in:
Yuya Ochiai
2015-11-24 00:12:48 +09:00
parent 493287d2e6
commit 6f18b921b2
2 changed files with 8 additions and 4 deletions

View File

@@ -22,6 +22,9 @@ var mainWindow = null;
var trayIcon = null;
var willAppQuit = false;
// For toast notification on windows
app.setAppUserModelId('yuya-oc.electron-mattermost');
// Quit when all windows are closed.
app.on('window-all-closed', function() {
// On OS X it is common for applications and their menu bar

View File

@@ -1,6 +1,7 @@
'use strict';
const ipc = require('electron').ipcRenderer;
const electron = require('electron');
const ipc = electron.ipcRenderer;
ipc.on('retrieveUnreadCount', function() {
var unreadCount = document.getElementsByClassName('unread-title').length;
@@ -23,9 +24,9 @@ if (process.platform === 'win32') {
}
*/
// Show window even if it is hidden when notification is clicked.
// Show window even if it is hidden/minimized when notification is clicked.
var NativeNotification = null;
if (process.platform === 'darwin') {
if (process.platform === 'darwin' || process.platform === 'win32') {
NativeNotification = Notification;
Notification = function(title, options) {
this.notification = new NativeNotification(title, options);
@@ -38,7 +39,7 @@ if (process.platform === 'darwin') {
};
Notification.prototype.__defineSetter__('onclick', function(callback) {
this.notification.onclick = function() {
require('remote').getCurrentWindow().show();
electron.remote.getCurrentWindow().show();
callback();
};
});