Skip to content

Commit 18edfcb

Browse files
Merge pull request #189 from ekonstantinidis/fix-autoupdate
Fix Autoupdate
2 parents 37089c4 + 1b9ec04 commit 18edfcb

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

images/press.png

0 Bytes
Loading

main.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const app = electron.app;
88
const dialog = electron.dialog;
99
const ipc = electron.ipcMain;
1010

11-
var ghReleases = require('electron-gh-releases');
11+
const GhReleases = require('electron-gh-releases');
1212
var Positioner = require('electron-positioner');
1313

1414
var AutoLaunch = require('auto-launch');
@@ -31,7 +31,7 @@ app.on('ready', function() {
3131
var appIcon = new Tray(iconIdle);
3232
var windowPosition = (isWindows) ? 'trayBottomCenter' : 'trayCenter';
3333

34-
function confirmAutoUpdate(quitAndUpdate) {
34+
function confirmAutoUpdate(installUpdate) {
3535
dialog.showMessageBox({
3636
type: 'question',
3737
buttons: ['Update & Restart', 'Cancel'],
@@ -42,33 +42,32 @@ app.on('ready', function() {
4242
console.log('Exit: ' + response);
4343
app.dock.hide();
4444
if (response === 0) {
45-
quitAndUpdate();
45+
installUpdate();
4646
}
4747
} );
4848
}
4949

5050
function checkAutoUpdate(showAlert) {
5151

52-
var autoUpdateOptions = {
52+
let autoUpdateOptions = {
5353
repo: 'ekonstantinidis/gitify',
5454
currentVersion: app.getVersion()
5555
};
5656

57-
var update = new ghReleases(autoUpdateOptions, function (autoUpdater) {
58-
autoUpdater
59-
.on('error', function(event, message) {
60-
console.log('ERRORED.');
61-
console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message);
62-
})
63-
.on('update-downloaded', function (event, releaseNotes, releaseName,
64-
releaseDate, updateUrl, quitAndUpdate) {
65-
console.log('Update downloaded');
66-
confirmAutoUpdate(quitAndUpdate);
67-
});
57+
const updater = new GhReleases(autoUpdateOptions);
58+
59+
updater.on('error', (event, message) => {
60+
console.log('ERRORED.');
61+
console.log('Event: ' + JSON.stringify(event) + '. MESSAGE: ' + message);
62+
});
63+
64+
updater.on('update-downloaded', (info) => {
65+
console.log('Update downloaded');
66+
confirmAutoUpdate(updater.install);
6867
});
6968

7069
// Check for updates
71-
update.check(function (err, status) {
70+
updater.check((err, status) => {
7271
if (err || !status) {
7372
if (showAlert) {
7473
dialog.showMessageBox({
@@ -82,7 +81,7 @@ app.on('ready', function() {
8281
}
8382

8483
if (!err && status) {
85-
update.download();
84+
updater.download();
8685
}
8786
});
8887
}

0 commit comments

Comments
 (0)