Permalink
Browse files

Check for Updates

  • Loading branch information...
1 parent d81e29d commit f9dac8beac6fc983730063eca52e88dc85948e73 @williambout committed Feb 18, 2017
Showing with 30 additions and 23 deletions.
  1. +29 −22 autoupdater.js
  2. +1 −1 menu.js
View
@@ -2,34 +2,41 @@ const {app, autoUpdater, dialog} = require('electron');
const version = app.getVersion();
const updaterFeedURL = 'https://paper-updates.herokuapp.com/update/darwin_64/' + version;
+let updateCheck;
-function appUpdater() {
+function appUpdater(checkType) {
+ updateCheck = checkType;
autoUpdater.setFeedURL(updaterFeedURL);
+ autoUpdater.checkForUpdates();
+}
- autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
- let message = app.getName() + ' ' + releaseName + ' is now available. It will be installed the next time you restart the application.';
- if (releaseNotes) {
- const splitNotes = releaseNotes.split(/[^\r]\n/);
- message += '\n\nRelease notes:\n';
- splitNotes.forEach(notes => {
- message += notes + '\n\n';
- });
- }
+autoUpdater.on('update-not-available', () => {
+ if (updateCheck === 'manual')
+ dialog.showMessageBox({message: 'No update available', detail: 'Version ' + version + ' is the latest version.'});
+});
- dialog.showMessageBox({
- type: 'question',
- buttons: ['Install and Relaunch', 'Later'],
- defaultId: 0,
- message: 'A new version of ' + app.getName() + ' has been downloaded',
- detail: message
- }, response => {
- if (response === 0) {
- setTimeout(() => autoUpdater.quitAndInstall(), 1);
- }
+autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
+ let message = app.getName() + ' ' + releaseName + ' is now available. It will be installed the next time you restart the application.';
+ if (releaseNotes) {
+ const splitNotes = releaseNotes.split(/[^\r]\n/);
+ message += '\n\nRelease notes:\n';
+ splitNotes.forEach(notes => {
+ message += notes + '\n\n';
});
+ }
+
+ dialog.showMessageBox({
+ type: 'question',
+ buttons: ['Install and Relaunch', 'Later'],
+ defaultId: 0,
+ message: 'A new version of ' + app.getName() + ' has been downloaded',
+ detail: message
+ }, response => {
+ if (response === 0) {
+ setTimeout(() => autoUpdater.quitAndInstall(), 1);
+ }
});
- autoUpdater.checkForUpdates();
-}
+});
exports = module.exports = {
appUpdater
View
@@ -11,7 +11,7 @@ module.exports = [
{
label: 'Check for Update',
click() {
- appUpdater();
+ appUpdater('manual');
}
},
{ type: 'separator' },

0 comments on commit f9dac8b

Please sign in to comment.