Skip to content

Commit

Permalink
Add update notifications on app start
Browse files Browse the repository at this point in the history
  • Loading branch information
rkclark committed Apr 29, 2018
1 parent 584059f commit fe14d39
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dev-app-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
owner: rkclark
repo: pullp
provider: github
30 changes: 29 additions & 1 deletion src/electron-starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ const isDev = require('electron-is-dev');
const path = require('path');
const url = require('url');
const electron = require('electron');
const { autoUpdater } = require('electron-updater');

const { app, shell, Menu } = electron;
autoUpdater.autoDownload = false;

const { app, shell, Menu, dialog } = electron;

// Set server port depending on electron environment
let serverPort = isDev ? '9821' : '9822';
Expand Down Expand Up @@ -88,6 +91,11 @@ app.on('ready', () => {
installExtension(REDUX_DEVTOOLS)
.then(name => console.log(`Added Extension: ${name}`))
.catch(err => console.log('An error occurred: ', err));

// eslint-disable-next-line global-require
const logger = require('electron-log');
autoUpdater.logger = logger;
autoUpdater.logger.transports.file.level = 'info';
}
const template = [
{
Expand Down Expand Up @@ -159,6 +167,26 @@ app.on('ready', () => {
} // eslint-disable-line
);
createMainWindow();
autoUpdater.checkForUpdates();

const linkToUpdatePage = response => {
if (response === 0) {
shell.openExternal('https://github.com/rkclark/pullp/releases');
}
};

autoUpdater.on('update-available', info => {
dialog.showMessageBox(
mainWindow,
{
type: 'info',
title: 'Update Available',
message: `Version ${info.version} of Pullp is now available!`,
buttons: ['Get the update', 'Skip for now'],
},
linkToUpdatePage,
);
});
});

// Quit when all windows are closed.
Expand Down

0 comments on commit fe14d39

Please sign in to comment.