Set Application User Model ID and use Electron's notification
This commit is contained in:
@@ -22,6 +22,9 @@ var mainWindow = null;
|
|||||||
var trayIcon = null;
|
var trayIcon = null;
|
||||||
var willAppQuit = false;
|
var willAppQuit = false;
|
||||||
|
|
||||||
|
// For toast notification on windows
|
||||||
|
app.setAppUserModelId('yuya-oc.electron-mattermost');
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
app.on('window-all-closed', function() {
|
app.on('window-all-closed', function() {
|
||||||
// On OS X it is common for applications and their menu bar
|
// On OS X it is common for applications and their menu bar
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const ipc = require('electron').ipcRenderer;
|
const electron = require('electron');
|
||||||
|
const ipc = electron.ipcRenderer;
|
||||||
|
|
||||||
ipc.on('retrieveUnreadCount', function() {
|
ipc.on('retrieveUnreadCount', function() {
|
||||||
var unreadCount = document.getElementsByClassName('unread-title').length;
|
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;
|
var NativeNotification = null;
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin' || process.platform === 'win32') {
|
||||||
NativeNotification = Notification;
|
NativeNotification = Notification;
|
||||||
Notification = function(title, options) {
|
Notification = function(title, options) {
|
||||||
this.notification = new NativeNotification(title, options);
|
this.notification = new NativeNotification(title, options);
|
||||||
@@ -38,7 +39,7 @@ if (process.platform === 'darwin') {
|
|||||||
};
|
};
|
||||||
Notification.prototype.__defineSetter__('onclick', function(callback) {
|
Notification.prototype.__defineSetter__('onclick', function(callback) {
|
||||||
this.notification.onclick = function() {
|
this.notification.onclick = function() {
|
||||||
require('remote').getCurrentWindow().show();
|
electron.remote.getCurrentWindow().show();
|
||||||
callback();
|
callback();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user