From 93f148fca33c2c1a89a7a8fc407828ea90aa68d6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sat, 3 Jun 2017 16:22:14 +0100 Subject: [PATCH] fix type electron vs remote don't break when running a non Squirrel Windows build that has an update url Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/vector/platform/ElectronPlatform.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index f84fe8d5..519cadc0 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -142,22 +142,30 @@ export default class ElectronPlatform extends VectorBasePlatform { const deferred = q.defer(); const _onUpdateAvailable = function() { - electron.autoUpdater.removeListener('update-not-available', _onUpdateNotAvailable); + remote.autoUpdater.removeListener('update-not-available', _onUpdateNotAvailable); + remote.autoUpdater.removeListener('error', _onError); deferred.resolve(updateStateEnum.DOWNLOADING); } - const _onUpdateNotAvailable = function() { - electron.autoUpdater.removeListener('update-available', _onUpdateAvailable); + remote.autoUpdater.removeListener('update-available', _onUpdateAvailable); + remote.autoUpdater.removeListener('error', _onError); deferred.resolve(updateStateEnum.NOTAVAILABLE); } + const _onError = function() { + remote.autoUpdater.removeListener('update-not-available', _onUpdateNotAvailable); + remote.autoUpdater.removeListener('update-available', _onUpdateAvailable); + deferred.resolve(updateStateEnum.ERROR); + } - electron.autoUpdater.once('update-available', _onUpdateAvailable); - electron.autoUpdater.once('update-not-available', _onUpdateNotAvailable); + remote.autoUpdater.once('update-available', _onUpdateAvailable); + remote.autoUpdater.once('update-not-available', _onUpdateNotAvailable); + remote.autoUpdater.once('error', _onError); - electron.ipcRenderer.send('checkForUpdates'); + remote.ipcRenderer.send('checkForUpdates'); return deferred.promise.timeout(10000).catch(() => { - electron.autoUpdater.removeListener('update-not-available', _onUpdateNotAvailable); - electron.autoUpdater.removeListener('update-available', _onUpdateAvailable); + remote.autoUpdater.removeListener('update-not-available', _onUpdateNotAvailable); + remote.autoUpdater.removeListener('update-available', _onUpdateAvailable); + remote.autoUpdater.removeListener('error', _onError); return updateStateEnum.TIMEOUT; }); }