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", "date-fns": "2.14.0",
"electron-is-dev": "^1.1.0", "electron-is-dev": "^1.1.0",
"electron-log": "4.2.1", "electron-log": "4.2.1",
"electron-settings": "^4.0.0",
"electron-updater": "4.3.1", "electron-updater": "4.3.1",
"eth-sig-util": "^2.5.3", "eth-sig-util": "^2.5.3",
"express": "^4.17.1", "express": "^4.17.1",

View File

@ -1,8 +1,8 @@
const os = require('os'); const os = require('os');
const fetch = require('node-fetch'); const { dialog } = require('electron');
const { dialog, app } = require('electron');
const log = require('electron-log'); const log = require('electron-log');
const isDev = require("electron-is-dev"); const settings = require('electron-settings').default;
const { autoUpdater } = require("electron-updater"); const { autoUpdater } = require("electron-updater");
// This logging setup is not required for auto-updates to work, // This logging setup is not required for auto-updates to work,
@ -19,7 +19,7 @@ let downloadProgress = 0;
function init(mainWindow) { function init(mainWindow) {
if(initialized || isDev) return; if(initialized) return;
initialized = true; initialized = true;
@ -27,24 +27,32 @@ function init(mainWindow) {
log.error(error == null ? "unknown" : (error.stack || error).toString()); 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({ dialog.showMessageBox({
type: 'info', type: 'info',
title: 'Found Updates', title: 'Found Updates',
message: 'There is a newer version of this app available. Do you want to update now?', 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, cancelId:1,
}).then(result => { }).then(result => {
if(result.response === 0){ if(result.response === 0){
autoUpdater.downloadUpdate(); autoUpdater.downloadUpdate();
} }
if(result.response === 2) {
settings.set('release', {version: info.version });
}
}); });
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
autoUpdater.logger.info("Update Downloaded..."); autoUpdater.logger.info("Update Downloaded...");
dialog.showMessageBox({ dialog.showMessageBox({
title: 'Install Updates', 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.', detail: 'A new version has been downloaded. Restart the application to apply the updates.',
buttons: ['Restart', 'Cancel'], buttons: ['Restart', 'Cancel'],
cancelId:1, cancelId:1,

View File

@ -6202,6 +6202,18 @@ electron-publish@22.7.0:
lazy-val "^1.0.4" lazy-val "^1.0.4"
mime "^2.4.5" 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: electron-to-chromium@^1.3.378, electron-to-chromium@^1.3.413, electron-to-chromium@^1.3.47:
version "1.3.459" version "1.3.459"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.459.tgz#49a43d78f60b5bf42312b636f3af43c695e0c652" 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" resolved "https://registry.yarnpkg.com/lodash.flatmap/-/lodash.flatmap-4.5.0.tgz#ef8cbf408f6e48268663345305c6acc0b778702e"
integrity sha1-74y/QI9uSCaGYzRTBcaswLd4cC4= 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: lodash.isequal@^4.5.0:
version "4.5.0" version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0" 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" resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= 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: lodash.sortby@^4.7.0:
version "4.7.0" version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" 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" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= 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: "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" version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
@ -11070,7 +11102,7 @@ mkdirp-promise@^5.0.1:
dependencies: dependencies:
mkdirp "*" mkdirp "*"
mkdirp@*: mkdirp@*, mkdirp@^1.0.4:
version "1.0.4" version "1.0.4"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
@ -17516,7 +17548,7 @@ write-file-atomic@2.4.1:
imurmurhash "^0.1.4" imurmurhash "^0.1.4"
signal-exit "^3.0.2" 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" version "3.0.3"
resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-3.0.3.tgz#56bd5c5a5c70481cd19c571bd39ab965a5de56e8" 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== integrity sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==