This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'electron' into desktop-v3.22.1
- Loading branch information
Showing
28 changed files
with
1,989 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
owner: gnosis | ||
repo: safe-react | ||
provider: github | ||
updaterCacheDirName: safe-react-updater |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { dialog } from 'electron' | ||
import settings from 'electron-settings' | ||
import log from 'electron-log' | ||
import { autoUpdater } from 'electron-updater' | ||
|
||
// This logging setup is not required for auto-updates to work, | ||
// but it sure makes debugging easier :) | ||
//------------------------------------------------------------------- | ||
|
||
autoUpdater.autoDownload = false | ||
autoUpdater.logger = log | ||
log.info('App starting...') | ||
|
||
let initialized = false | ||
let downloadProgress = 0 | ||
|
||
function init() { | ||
if (initialized) return | ||
|
||
initialized = true | ||
|
||
autoUpdater.on('error', (error) => { | ||
log.error(error == null ? 'unknown' : (error.stack || error).toString()) | ||
}) | ||
|
||
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?', | ||
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: releaseName, | ||
detail: 'A new version has been downloaded. Restart the application to apply the updates.', | ||
buttons: ['Restart', 'Cancel'], | ||
cancelId: 1, | ||
}) | ||
.then((result) => { | ||
if (result.response === 0) { | ||
autoUpdater.quitAndInstall() | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
autoUpdater.on('download-progress', (d) => { | ||
downloadProgress = d.percent | ||
autoUpdater.logger?.info(downloadProgress) | ||
}) | ||
|
||
autoUpdater.checkForUpdates() | ||
} | ||
|
||
module.exports = { | ||
init, | ||
} |
Oops, something went wrong.