Skip to content

Commit

Permalink
Automatically check for updates on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
cristianobarros committed Sep 15, 2017
1 parent 35d38a5 commit 019d1ea
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions app/containers/app.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {ipcRenderer, webFrame, remote} from 'electron';
import {ipcRenderer, webFrame, remote, shell} from 'electron';

import config from './../package.json';

import React, {PureComponent} from 'react';

Expand Down Expand Up @@ -126,6 +128,15 @@ export default class App extends PureComponent {
});
},
});

UpdateChecker.hasUpdateAvaliable()
.then(hasUpdateAvaliable => {
if (hasUpdateAvaliable) {
this.confirmDownloadNewVersion();
}
})
.catch(error => console.error(error));

}

collect(props) {
Expand Down Expand Up @@ -329,12 +340,18 @@ export default class App extends PureComponent {
UpdateChecker.hasUpdateAvaliable()
.then(hasUpdateAvaliable => {
if (hasUpdateAvaliable) {
alert('There is a newer version available for download');
this.confirmDownloadNewVersion();
} else {
alert('You already have the latest version');
alert('You already have the latest version.');
}
})
.catch(error => alert('An error occurred while checking for updates'));
.catch(error => alert('An error occurred while checking for updates.'));
}

confirmDownloadNewVersion() {
if (confirm('There is a newer version available. Do you want to download it?')) {
shell.openExternal(config.repository + '/releases/latest');
}
}

getSql() {
Expand Down

0 comments on commit 019d1ea

Please sign in to comment.