From c5fad7cdd86026a13e3b90b9a614d90ef21137b5 Mon Sep 17 00:00:00 2001 From: Mati Dastugue Date: Wed, 3 Jun 2020 14:37:50 -0300 Subject: [PATCH] Add dialog and skip version --- dev-app-update.yml | 4 ++++ public/auto-updater/index.js | 24 ++++++++++++++++-------- yarn.lock | 12 ++++++++++-- 3 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 dev-app-update.yml diff --git a/dev-app-update.yml b/dev-app-update.yml new file mode 100644 index 00000000..44400372 --- /dev/null +++ b/dev-app-update.yml @@ -0,0 +1,4 @@ +owner: gnosis +repo: safe-react +provider: github +updaterCacheDirName: safe-react-updater diff --git a/public/auto-updater/index.js b/public/auto-updater/index.js index 8fbb8404..d3b96607 100644 --- a/public/auto-updater/index.js +++ b/public/auto-updater/index.js @@ -1,8 +1,8 @@ const os = require('os'); -const fetch = require('node-fetch'); -const { dialog, app } = require('electron'); +const { dialog } = require('electron'); const log = require('electron-log'); -const isDev = require("electron-is-dev"); +const settings =require('electron-settings'); + const { autoUpdater } = require("electron-updater"); // This logging setup is not required for auto-updates to work, @@ -19,7 +19,7 @@ let downloadProgress = 0; function init(mainWindow) { - if(initialized || isDev) return; + if(initialized) return; initialized = true; @@ -27,24 +27,32 @@ function init(mainWindow) { log.error(error == null ? "unknown" : (error.stack || error).toString()); }); - autoUpdater.on('update-available', () => { + autoUpdater.on('update-available', (info) => { + if(info.version === settings.get('release.version')) { + log.info(`Skipped version ${info.version}`); + return; + } dialog.showMessageBox({ type: 'info', title: 'Found Updates', message: 'There is a newer version of this app available. Do you want to update now?', - buttons: ['Yes', 'Remind me later'], + detail: info.releaseNotes.replace(/(<([^>]+)>)/g, ""), + buttons: ['Install Update', 'Remind me later','Skip this version'], cancelId:1, - }).then(result => { + }).then(async result => { if(result.response === 0){ autoUpdater.downloadUpdate(); } + if(result.response === 2) { + await settings.set('release', {version: info.version }); + } }); autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { autoUpdater.logger.info("Update Downloaded..."); dialog.showMessageBox({ title: 'Install Updates', - message: process.platform === 'win32' ? releaseNotes : releaseName, + message: releaseName, detail: 'A new version has been downloaded. Restart the application to apply the updates.', buttons: ['Restart', 'Cancel'], cancelId:1, diff --git a/yarn.lock b/yarn.lock index 8991db61..4739353e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6278,6 +6278,14 @@ electron-publish@22.2.0: lazy-val "^1.0.4" mime "^2.4.4" +electron-settings@^3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/electron-settings/-/electron-settings-3.2.0.tgz#01461e153f95b6f18adbe0c360c70898eb0f43c3" + integrity sha512-7U+vDKd5Gch4Z9K6FjGq80eB3Anwz2GuPc2h/6hOiuvZrS1w+UNPcAA0oAU8G1s9sWAVEadCsr4ZJR6J4iTdzA== + dependencies: + clone "^2.1.1" + jsonfile "^4.0.0" + electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.413, electron-to-chromium@^1.3.47: version "1.3.453" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.453.tgz#758a8565a64b7889b27132a51d2abb8b135c9d01" @@ -17021,9 +17029,9 @@ web3-provider-engine@^15.0.4: xhr "^2.2.0" xtend "^4.0.1" -"web3-provider-engine@git+https://github.com/trufflesuite/provider-engine.git#web3-one": +"web3-provider-engine@https://github.com/trufflesuite/provider-engine#web3-one": version "14.0.6" - resolved "git+https://github.com/trufflesuite/provider-engine.git#3538c60bc4836b73ccae1ac3f64c8fed8ef19c1a" + resolved "https://github.com/trufflesuite/provider-engine#3538c60bc4836b73ccae1ac3f64c8fed8ef19c1a" dependencies: async "^2.5.0" backoff "^2.5.0"