Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit 70cce19

Browse files
committed
Assume Update Code Works
1 parent 9171371 commit 70cce19

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

index.js

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const url = require('url');
22
const path = require('path');
3-
const {app, BrowserWindow} = require('electron');
3+
const {app, BrowserWindow, dialog} = require('electron');
44

55
let win;
66

@@ -11,6 +11,30 @@ const server = 'http://zfaucet.org:3005';
1111
const feed = `${server}/update/${process.platform}/${version}`;
1212

1313
autoUpdater.setFeedURL(feed);
14+
autoUpdater.checkForUpdates(); // check on launch
15+
16+
setInterval(() => {
17+
autoUpdater.checkForUpdates();
18+
}, 60 * 1000);
19+
20+
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
21+
const dialogOpts = {
22+
type: 'info',
23+
buttons: ['Restart', 'Later'],
24+
title: 'Application Update',
25+
message: process.platform === 'win32' ? releaseNotes : releaseName,
26+
detail: 'A new version has been downloaded. Restart the application to apply the updates.'
27+
};
28+
29+
dialog.showMessageBox(dialogOpts, response => {
30+
if (response === 0) autoUpdater.quitAndInstall();
31+
});
32+
});
33+
34+
autoUpdater.on('error', message => {
35+
console.error('There was a problem updating the application');
36+
console.error(message);
37+
});
1438

1539
app.on('ready', () => {
1640
win = new BrowserWindow({width: 800, height: 600});

0 commit comments

Comments
 (0)