From c3cdda354e9ec726633161c8ade2a8df237997b0 Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Mon, 6 Feb 2017 00:38:27 -0300 Subject: [PATCH] added node-notifier; showing plugin notifications. --- package.json | 1 + src/plugins.js | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 6c293780..242e4476 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "mkdirp": "^0.5.1", "musicmetadata": "^2.0.2", "network-address": "^1.1.0", + "node-notifier": "^5.0.2", "parse-torrent": "^5.7.3", "prettier-bytes": "^1.0.1", "react": "^15.2.1", diff --git a/src/plugins.js b/src/plugins.js index 281c1877..17864137 100644 --- a/src/plugins.js +++ b/src/plugins.js @@ -2,8 +2,8 @@ const {exec} = require('child_process') const {resolve, basename} = require('path') const {writeFileSync} = require('fs') const State = require('./renderer/lib/state') +const notifier = require('node-notifier') -const {app, dialog} = require('electron') const {sync: mkdirpSync} = require('mkdirp') const ms = require('ms') const shellEnv = require('shell-env') @@ -55,6 +55,7 @@ module.exports = class Plugins { if (plugins !== this.plugins) { const id = this.getId(plugins) if (this.id !== id) { + this.alert('Installing plugins...') log('UPDATING...') this.id = id this.plugins = plugins @@ -156,7 +157,8 @@ module.exports = class Plugins { // notify watchers if (this.forceUpdate || changed) { this.watchers.forEach(fn => fn(err, {forceUpdate: this.forceUpdate})) - log('instalation completed') + this.alert('Installation completed') + log('installation completed') } // save state @@ -221,12 +223,11 @@ module.exports = class Plugins { } alert (message) { - log(message) - // TODO: display notifications - // dialog.showMessageBox({ - // message, - // buttons: ['Ok'] - // }) + notifier.notify({ + title: 'WebTorrent Plugins', + // icon: config.icon, // TODO: save icon in webtorrent local folder and set config.icon + message: message + }) } isLocalPath (string) { @@ -333,9 +334,7 @@ module.exports = class Plugins { } if (installNeeded) this.updatePlugins() - - return plugins.map(load) - .filter(v => Boolean(v)) + return plugins.map(load).filter(v => Boolean(v)) } onApp (app) {