diff --git a/browser/main/Main.js b/browser/main/Main.js index 1c265206..e0230cec 100644 --- a/browser/main/Main.js +++ b/browser/main/Main.js @@ -18,6 +18,7 @@ import { getLocales } from 'browser/lib/Languages' import applyShortcuts from 'browser/main/lib/shortcutManager' import { chooseTheme, applyTheme } from 'browser/main/lib/ThemeManager' import { push } from 'connected-react-router' +import { ipcRenderer } from 'electron' const path = require('path') const electron = require('electron') @@ -184,6 +185,7 @@ class Main extends React.Component { this.toggleMenuBarVisible.bind(this) ) eventEmitter.on('dispatch:push', this.changeRoutePush.bind(this)) + eventEmitter.on('update', () => ipcRenderer.send('update-check', 'manual')) } componentWillUnmount() { diff --git a/lib/main-app.js b/lib/main-app.js index 3c82299f..19d3f91d 100644 --- a/lib/main-app.js +++ b/lib/main-app.js @@ -36,20 +36,25 @@ const updater = new GhReleases(ghReleasesOpts) // Check for updates // `status` returns true if there is a new update available -function checkUpdate() { - if (!isPackaged) { - // Prevents app from attempting to update when in dev mode. - console.log('Updates are disabled in Development mode, see main-app.js') - return true - } - if (!electronConfig.get('autoUpdateEnabled', true)) return - if (process.platform === 'linux' || isUpdateReady) { - return true - } +function checkUpdate(manualTriggered = false) { + // if (!isPackaged) { + // Prevents app from attempting to update when in dev mode. + // console.log('Updates are disabled in Development mode, see main-app.js') + // return true + // } + if (!electronConfig.get('autoUpdateEnabled', true) && !manualTriggered) return + // if (process.platform === 'linux' || isUpdateReady) { + // return true + // } + updater.check((err, status) => { if (err) { var isLatest = err.message === 'There is no newer version.' if (!isLatest) console.error('Updater error! %s', err.message) + mainWindow.webContents.send( + 'update-not-found', + isLatest ? 'There is no newer version.' : 'Updater error' + ) return } if (status) { @@ -113,7 +118,7 @@ app.on('ready', function() { if (isUpdateReady) { mainWindow.webContents.send('update-ready', 'Update available!') } else { - checkUpdate() + checkUpdate(msg === 'manual') } }) }, 10 * 1000) diff --git a/lib/main-menu.js b/lib/main-menu.js index db66c8ed..3be0576c 100644 --- a/lib/main-menu.js +++ b/lib/main-menu.js @@ -3,7 +3,6 @@ const BrowserWindow = electron.BrowserWindow const shell = electron.shell const ipc = electron.ipcMain const mainWindow = require('./main-window') -const { checkUpdate } = require('./main-app') const os = require('os') const macOS = process.platform === 'darwin' @@ -186,7 +185,7 @@ const file = { { label: 'Update', click() { - checkUpdate() + mainWindow.webContents.send('update') } }, {