Merge pull request #997 from gnosis/feature/updateDialog

Update Desktop App dialog
This commit is contained in:
Mati Dastugue 2020-06-08 13:15:47 -03:00 committed by GitHub
commit 2b02f06db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 9 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

@ -167,6 +167,7 @@
"date-fns": "2.14.0",
"electron-is-dev": "^1.1.0",
"electron-log": "4.2.1",
"electron-settings": "^4.0.0",
"electron-updater": "4.3.1",
"eth-sig-util": "^2.5.3",
"express": "^4.17.1",

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').default;
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 => {
if(result.response === 0){
autoUpdater.downloadUpdate();
}
if(result.response === 2) {
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

@ -6202,6 +6202,18 @@ electron-publish@22.7.0:
lazy-val "^1.0.4"
mime "^2.4.5"
electron-settings@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/electron-settings/-/electron-settings-4.0.0.tgz#e30938204ceecf83241a9f70f16395a95705df6e"
integrity sha512-9Msvqk8pu3lT71PUIVfqlzEx9zrXmq+5AYHc7dcftD0gbDzpYP6aBIx6En6rn1352IRTSE6JbnE/ud4SpfU1mg==
dependencies:
lodash.get "^4.4.2"
lodash.has "^4.5.2"
lodash.set "^4.3.2"
lodash.unset "^4.5.2"
mkdirp "^1.0.4"
write-file-atomic "^3.0.3"
electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.413, electron-to-chromium@^1.3.47:
version "1.3.459"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.459.tgz#49a43d78f60b5bf42312b636f3af43c695e0c652"
@ -10489,6 +10501,16 @@ lodash.flatmap@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz#ef8cbf408f6e48268663345305c6acc0b778702e"
integrity sha1-74y/QI9uSCaGYzRTBcaswLd4cC4=
lodash.get@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
lodash.has@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.has/-/lodash.has-4.5.2.tgz#d19f4dc1095058cccbe2b0cdf4ee0fe4aa37c862"
integrity sha1-0Z9NwQlQWMzL4rDN9O4P5Ko3yGI=
lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
@ -10499,6 +10521,11 @@ lodash.memoize@^4.1.2:
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"
integrity sha1-2HV7HagH3eJIFrDWqEvqGnYjCyM=
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
@ -10524,6 +10551,11 @@ lodash.uniq@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
lodash.unset@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.unset/-/lodash.unset-4.5.2.tgz#370d1d3e85b72a7e1b0cdf2d272121306f23e4ed"
integrity sha1-Nw0dPoW3Kn4bDN8tJyEhMG8j5O0=
"lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4, lodash@^4.17.5, lodash@~4.17.12:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
@ -11070,7 +11102,7 @@ mkdirp-promise@^5.0.1:
dependencies:
mkdirp "*"
mkdirp@*:
mkdirp@*, mkdirp@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
@ -17516,7 +17548,7 @@ write-file-atomic@2.4.1:
imurmurhash "^0.1.4"
signal-exit "^3.0.2"
write-file-atomic@^3.0.0:
write-file-atomic@^3.0.0, write-file-atomic@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8"
integrity sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==