move all logic, make bar more generic

pass through actual errors
and tidy
needs testing

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-06-11 19:19:17 +01:00
parent c4fd139586
commit a520f0bfed
6 changed files with 138 additions and 96 deletions

View file

@ -67,4 +67,24 @@ module.exports.start = function startAutoUpdate(updateBaseUrl) {
}
ipcMain.on('install_update', installUpdate);
ipcMain.on('checkForUpdates', pollForUpdates);
let ipcChannel;
ipcMain.on('check_updates', function(event) {
ipcChannel = event.sender;
pollForUpdates();
// event.sender.send('check_updates') // true/false/error = available(downloading)/notAvailable/error
});
function ipcChannelSendUpdateStatus(status) {
if (ipcChannel) {
ipcChannel.send('check_updates', status);
}
}
autoUpdater.on('update-available', function() {
ipcChannelSendUpdateStatus(true);
}).on('update-not-available', function() {
ipcChannelSendUpdateStatus(false);
}).on('error', function(error) {
ipcChannelSendUpdateStatus(error.message);
});