-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
68 additions
and
1 deletion.
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
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,54 @@ | ||
// Modules and variable definition | ||
const { dialog } = require('electron') | ||
const { autoUpdater } = require('electron-updater') | ||
|
||
// Uncomment below for updater logging | ||
// autoUpdater.logger = require('electron-log') | ||
// autoUpdater.logger.transports.file.level = 'info' | ||
|
||
// Disabable auto-download of updates | ||
autoUpdater.autoDownload = false | ||
|
||
// Check for app updates | ||
module.exports = () => { | ||
autoUpdater.on('error', (err) => { | ||
console.error(err) | ||
}) | ||
// Check for updates | ||
autoUpdater.checkForUpdates() | ||
// Listen for update | ||
autoUpdater.on('update-available', () => { | ||
// Prompt for user to update | ||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Update Available', | ||
message: 'A new version of Temporal is available. Do you want to update now?', | ||
buttons: ['Update', 'Cancel'], | ||
defaultId: 0, | ||
cancelId: 1 | ||
}).then(result => { | ||
// Download if Update chosen | ||
if (result.response === 0) { | ||
autoUpdater.downloadUpdate() | ||
} | ||
}) | ||
}) | ||
|
||
// Listen for update | ||
autoUpdater.on('update-downloaded', () => { | ||
// Prompt for user to update | ||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Update Ready', | ||
message: 'Install and restart now?', | ||
buttons: ['Install', 'Later'], | ||
defaultId: 0, | ||
cancelId: 1 | ||
}).then(result => { | ||
// Download if Update chosen | ||
if (result.response === 0) { | ||
autoUpdater.quitAndInstall(false, true) | ||
} | ||
}) | ||
}) | ||
} |