added node-notifier; showing plugin notifications.

This commit is contained in:
Alberto Miranda
2017-02-06 00:38:27 -03:00
parent 25ed12ba3c
commit c3cdda354e
2 changed files with 11 additions and 11 deletions

View File

@@ -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",

View File

@@ -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) {