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

Commit

Permalink
Setup auto update - Closes #196
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Sep 22, 2017
1 parent bd48d51 commit af892a4
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { app } = electron;
const { BrowserWindow } = electron;
const { Menu } = electron;
const { ipcMain } = electron;
const { autoUpdater } = electron;

let win;
const copyright = `Copyright © 2016 - ${new Date().getFullYear()} Lisk Foundation`;
Expand Down Expand Up @@ -216,3 +217,34 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
ipcMain.on('proxyCredentialsEntered', (event, username, password) => {
global.myTempFunction(username, password);
});


try {
// TODO: change to the final url once it's known
const feedUrl = `https://localhost:8082/?version=${app.getVersion()}&platform=${process.platform}`;
autoUpdater.setFeedURL(feedUrl);

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

autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate) => {
const index = electron.dialog.showMessageBox(win, {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Lisk Nano',
message: 'The new version has been downloaded. Please restart the application to apply the updates.',
detail: `${releaseName}\n\n${releaseNotes}`,
});

if (index === 1) {
return;
}

quitAndUpdate();
});
} catch (e) {
// because autoUpdater doesn't work if the build is not signed
console.log(e);
}

0 comments on commit af892a4

Please sign in to comment.