-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add autoupdater as menu option, version bump to test
- Loading branch information
Showing
5 changed files
with
103 additions
and
26 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
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,62 @@ | ||
/** | ||
* updater.js | ||
* | ||
* Please use manual update only when it is really required, otherwise please use recommended non-intrusive auto update. | ||
* | ||
* Import steps: | ||
* 1. create `updater.js` for the code snippet | ||
* 2. require `updater.js` for menu implementation, and set `checkForUpdates` callback from `updater` for the click property of `Check Updates...` MenuItem. | ||
*/ | ||
const { dialog } = require('electron') | ||
const { autoUpdater } = require('electron-updater') | ||
|
||
let updater = {} | ||
autoUpdater.autoDownload = false | ||
|
||
autoUpdater.on('error', (error) => { | ||
dialog.showErrorBox('Error: ', error == null ? "unknown" : (error.stack || error).toString()) | ||
}) | ||
|
||
autoUpdater.on('update-available', () => { | ||
dialog.showMessageBox({ | ||
type: 'info', | ||
title: 'Found Updates', | ||
message: 'Found updates, do you want update now?', | ||
buttons: ['Sure', 'No'] | ||
}, (buttonIndex) => { | ||
if (buttonIndex === 0) { | ||
autoUpdater.downloadUpdate() | ||
} | ||
else { | ||
updater.enabled = true | ||
// updater = null | ||
} | ||
}) | ||
}) | ||
|
||
autoUpdater.on('update-not-available', () => { | ||
dialog.showMessageBox({ | ||
title: 'No Updates', | ||
message: 'Current version is up-to-date.' | ||
}) | ||
updater.enabled = true | ||
// updater = null | ||
}) | ||
|
||
autoUpdater.on('update-downloaded', () => { | ||
dialog.showMessageBox({ | ||
title: 'Install Updates', | ||
message: 'Updates downloaded, application will be quit for update...' | ||
}, () => { | ||
setImmediate(() => autoUpdater.quitAndInstall()) | ||
}) | ||
}) | ||
|
||
// export this to MenuItem click callback | ||
// function checkForUpdates (menuItem, focusedWindow, event) { | ||
function checkForUpdates() { | ||
// updater = menuItem | ||
updater.enabled = false | ||
autoUpdater.checkForUpdates() | ||
} | ||
module.exports.checkForUpdates = checkForUpdates |
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