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

Commit

Permalink
Assume Update Code Works
Browse files Browse the repository at this point in the history
  • Loading branch information
super3 committed Apr 1, 2018
1 parent 9171371 commit 70cce19
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const url = require('url');
const path = require('path');
const {app, BrowserWindow} = require('electron');
const {app, BrowserWindow, dialog} = require('electron');

let win;

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

autoUpdater.setFeedURL(feed);
autoUpdater.checkForUpdates(); // check on launch

setInterval(() => {
autoUpdater.checkForUpdates();
}, 60 * 1000);

autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'A new version has been downloaded. Restart the application to apply the updates.'
};

dialog.showMessageBox(dialogOpts, response => {
if (response === 0) autoUpdater.quitAndInstall();
});
});

autoUpdater.on('error', message => {
console.error('There was a problem updating the application');
console.error(message);
});

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

0 comments on commit 70cce19

Please sign in to comment.