diff options
Diffstat (limited to 'src/electron/ipc-api/autoUpdate.js')
-rw-r--r-- | src/electron/ipc-api/autoUpdate.js | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/src/electron/ipc-api/autoUpdate.js b/src/electron/ipc-api/autoUpdate.js index 6a3314b2b..506aecdf7 100644 --- a/src/electron/ipc-api/autoUpdate.js +++ b/src/electron/ipc-api/autoUpdate.js | |||
@@ -4,24 +4,33 @@ import { autoUpdater } from 'electron-updater'; | |||
4 | const debug = require('debug')('Ferdi:ipcApi:autoUpdate'); | 4 | const debug = require('debug')('Ferdi:ipcApi:autoUpdate'); |
5 | 5 | ||
6 | export default (params) => { | 6 | export default (params) => { |
7 | if (process.platform === 'darwin' || process.platform === 'win32' || process.env.APPIMAGE) { | 7 | const disableUpdates = Boolean(params.settings.app.get('noUpdates')); |
8 | |||
9 | if (disableUpdates) { | ||
10 | autoUpdater.autoInstallOnAppQuit = false; | ||
11 | autoUpdater.autoDownload = false; | ||
12 | } else if (process.platform === 'darwin' || process.platform === 'win32' || process.env.APPIMAGE) { | ||
8 | ipcMain.on('autoUpdate', (event, args) => { | 13 | ipcMain.on('autoUpdate', (event, args) => { |
9 | try { | 14 | const enableUpdate = !params.settings.app.get('noUpdates'); |
10 | autoUpdater.autoInstallOnAppQuit = false; | 15 | |
11 | autoUpdater.allowPrerelease = Boolean(params.settings.app.get('beta')); | 16 | if (enableUpdate) { |
12 | if (args.action === 'check') { | 17 | try { |
13 | autoUpdater.checkForUpdates(); | 18 | autoUpdater.autoInstallOnAppQuit = false; |
14 | } else if (args.action === 'install') { | 19 | autoUpdater.allowPrerelease = Boolean(params.settings.app.get('beta')); |
15 | debug('install update'); | 20 | if (args.action === 'check') { |
16 | autoUpdater.quitAndInstall(); | 21 | autoUpdater.checkForUpdates(); |
17 | // we need to send a quit event | 22 | } else if (args.action === 'install') { |
18 | setTimeout(() => { | 23 | debug('install update'); |
19 | app.quit(); | 24 | autoUpdater.quitAndInstall(); |
20 | }, 20); | 25 | // we need to send a quit event |
26 | setTimeout(() => { | ||
27 | app.quit(); | ||
28 | }, 20); | ||
29 | } | ||
30 | } catch (e) { | ||
31 | console.error(e); | ||
32 | event.sender.send('autoUpdate', { error: true }); | ||
21 | } | 33 | } |
22 | } catch (e) { | ||
23 | console.error(e); | ||
24 | event.sender.send('autoUpdate', { error: true }); | ||
25 | } | 34 | } |
26 | }); | 35 | }); |
27 | 36 | ||
@@ -32,10 +41,14 @@ export default (params) => { | |||
32 | 41 | ||
33 | autoUpdater.on('update-available', (event) => { | 42 | autoUpdater.on('update-available', (event) => { |
34 | debug('update-available'); | 43 | debug('update-available'); |
35 | params.mainWindow.webContents.send('autoUpdate', { | 44 | |
36 | version: event.version, | 45 | const enableUpdate = !params.settings.app.get('noUpdates'); |
37 | available: true, | 46 | if (enableUpdate) { |
38 | }); | 47 | params.mainWindow.webContents.send('autoUpdate', { |
48 | version: event.version, | ||
49 | available: true, | ||
50 | }); | ||
51 | } | ||
39 | }); | 52 | }); |
40 | 53 | ||
41 | autoUpdater.on('download-progress', (progressObj) => { | 54 | autoUpdater.on('download-progress', (progressObj) => { |