From 653f869bb68b1db2af536ac6813d85549ebe4b9e Mon Sep 17 00:00:00 2001 From: Taylor Hanayik Date: Wed, 12 Jul 2017 13:08:38 -0400 Subject: [PATCH] added user check for update and video recording stop alert --- app.js | 21 +++++++++++++++++++++ core.js | 7 ++++++- menu.js | 5 +++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index a20f104..fca240c 100644 --- a/app.js +++ b/app.js @@ -17,6 +17,8 @@ const os = require("os"); var platform = os.platform() + '_' + os.arch(); var version = app.getVersion(); var updateResponse +var ipcMain = require('electron').ipcMain; +var shouldShowMessageNow = false app.setName("PNT") //icon credit: http://www.flaticon.com/authors/madebyoliver // Keep a global reference of the window object, if you don't, the window will @@ -109,6 +111,12 @@ app.on('activate', function () { } }) +ipcMain.on('user-requests-update', function() { + shouldShowMessageNow = true + console.log('user requested an update check') + autoUpdater.checkForUpdates() +}) + autoUpdater.on('error', function(err) { console.log(err) }) @@ -134,6 +142,19 @@ autoUpdater.on('update-available', function(){ }) autoUpdater.on('update-not-available', function(){ console.log('update not available') + if (shouldShowMessageNow) { + var dialogOptions = { + type: "info", + buttons: ["Ok"], + defaultId: 0, + title: "No update available", + message: "There are no updates available. You have the most recent version!", + cancelId: 0 + } + dialog.showMessageBox(mainWindow, dialogOptions , function (response) { + + }) +} }) autoUpdater.on('update-downloaded', function(){ if (updateResponse == 1) { diff --git a/core.js b/core.js index ab0e9f6..63508c6 100644 --- a/core.js +++ b/core.js @@ -11,6 +11,7 @@ const ffmpeg = appRootDir+'/ffmpeg/ffmpeg' const exec = require( 'child_process' ).exec const si = require('systeminformation'); const mkdirp = require('mkdirp'); +var ipcRenderer = require('electron').ipcRenderer; var moment = require('moment') var content = document.getElementById("contentDiv") var picNum = document.getElementById("picNumID") @@ -42,7 +43,10 @@ var userDataPath = path.join(app.getPath('userData'),'Data') makeSureUserDataFolderIsThere() var savePath - +function checkForUpdateFromRender() { + ipcRenderer.send('user-requests-update') + //alert('checked for update') +} @@ -216,6 +220,7 @@ function ff() { exec(cmd,{maxBuffer: 2000 * 1024}, (error, stdout, stderr) => { if (error) { console.error(`exec error: ${error}`) + alert('Recording stopped!') return } // console.log(`stdout: ${stdout}`); diff --git a/menu.js b/menu.js index 4159a44..3c54412 100644 --- a/menu.js +++ b/menu.js @@ -99,6 +99,11 @@ if (process.platform === 'darwin') { { role: 'about' }, + { + label: 'Check for update', + type: 'normal', + click() {checkForUpdateFromRender()} + }, { type: 'separator' },