From d4d1c32288665832b87adfd3938a06cc9e256642 Mon Sep 17 00:00:00 2001 From: Rokt33r Date: Tue, 24 Nov 2015 06:17:49 +0900 Subject: [PATCH] =?UTF-8?q?notification=20=E3=83=87=E3=83=90=E3=83=83?= =?UTF-8?q?=E3=82=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- browser/main/index.js | 6 +++--- main.js | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/browser/main/index.js b/browser/main/index.js index b6090561..c18e3008 100644 --- a/browser/main/index.js +++ b/browser/main/index.js @@ -24,9 +24,9 @@ function notify (...args) { return new window.Notification(...args) } -ipc.on('notify', function (title, message) { - notify(title, { - body: message +ipc.on('notify', function (e, payload) { + notify(payload.title, { + body: payload.body }) }) diff --git a/main.js b/main.js index c8fc050a..1c1c9c19 100644 --- a/main.js +++ b/main.js @@ -22,34 +22,40 @@ var appQuit = false var version = app.getVersion() var versionText = (version == null || version.length === 0) ? 'DEV version' : 'v' + version var versionNotified = false + +function notify (title, body) { + if (mainWindow != null) { + mainWindow.webContents.send('notify', { + title: title, + body: body + }) + } +} + autoUpdater .on('update-downloaded', function (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) { update = quitAndUpdate if (mainWindow != null) { - mainWindow.webContents.send('notify', 'Ready to Update! ' + releaseName, 'Click update button on Main window.') + notify('Ready to Update! ' + releaseName, 'Click update button on Main window.') mainWindow.webContents.send('update-available', 'Update available!') } }) .on('error', function (err, message) { console.error(err) - if (mainWindow != null && !versionNotified) { - mainWindow.webContents.send('notify', 'Updater error!', message) - } + notify('Updater error!', message) }) // .on('checking-for-update', function () { // // Connecting // console.log('checking...') // }) .on('update-available', function () { - if (mainWindow != null) { - mainWindow.webContents.send('notify', 'Update is available!', 'Download started.. wait for the update ready.') - } + notify('Update is available!', 'Download started.. wait for the update ready.') }) .on('update-not-available', function () { if (mainWindow != null && !versionNotified) { versionNotified = true - mainWindow.webContents.send('notify', 'Latest Build!! ' + versionText, 'Hope you to enjoy our app :D') + notify('Latest Build!! ' + versionText, 'Hope you to enjoy our app :D') } }) @@ -59,7 +65,7 @@ app.on('ready', function () { appQuit = true }) - autoUpdater.setFeedURL('http://orbital.b00st.io/rokt33r/boost-dev/latest?version=' + version) + autoUpdater.setFeedURL('https://orbital.b00st.io/rokt33r/boost-dev/latest?version=' + version) var template = require('./atom-lib/menu-template') var menu = Menu.buildFromTemplate(template)