electron-main-notification
Advanced tools
Comparing version 1.0.0 to 1.0.1
20
index.js
@@ -8,4 +8,4 @@ const { ipcMain, BrowserWindow } = require('electron') | ||
module.exports = function (title, opts, onClick) { | ||
if (window) return sendNotification(title, opts, onClick) | ||
module.exports = function (title, opts, onClick, onClose) { | ||
if (window) return sendNotification(title, opts, onClick, onClose) | ||
@@ -17,14 +17,20 @@ window = new BrowserWindow({ | ||
window.on('ready-to-show', () => { | ||
sendNotification(title, opts, onClick) | ||
sendNotification(title, opts, onClick, onClose) | ||
}) | ||
ipcMain.on('display-notification-onclick', (event, uid) => { | ||
if (!callbacks[uid]) return | ||
callbacks[uid].call(this) | ||
if (!callbacks[uid].onClick) return | ||
callbacks[uid].onClick.call(this) | ||
}) | ||
ipcMain.on('display-notification-onclose', (event, uid) => { | ||
if (!callbacks[uid].onClose) return | ||
callbacks[uid].onClose.call(this) | ||
}) | ||
} | ||
function sendNotification (title, opts, onClick) { | ||
function sendNotification (title, opts, onClick, onClose) { | ||
var uid = uuid.v1() | ||
if (onClick) callbacks[uid] = onClick | ||
callbacks[uid] = {}; | ||
if (onClick) callbacks[uid].onClick = onClick | ||
if (onClose) callbacks[uid].onClose = onClose | ||
window.webContents.send('display-notification', { | ||
@@ -31,0 +37,0 @@ title: title, |
{ | ||
"name": "electron-main-notification", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Display notifications from the electron main process", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
3268
5
34