Add dialog and skip version

This commit is contained in:
Mati Dastugue 2020-06-03 14:37:50 -03:00
parent 3bcdb80f26
commit c5fad7cdd8
3 changed files with 30 additions and 10 deletions

4
dev-app-update.yml Normal file
View File

@ -0,0 +1,4 @@
owner: gnosis
repo: safe-react
provider: github
updaterCacheDirName: safe-react-updater

View File

@ -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,

View File

@ -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"