Last active
February 22, 2017 22:40
-
-
Save weedgrease/f250bc557e21a750d753291a1f6ce710 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {app, autoUpdater, dialog} = require('electron'); | |
const ms = require('ms'); | |
const platform = process.platform === 'darwin' ? 'osx' : process.platform; | |
const version = app.getVersion(); | |
const feedUrl = `https://my-updates-here.herokuapp.com/update/${platform}`; | |
export default class AutoUpdater { | |
constructor(mainWindow) { | |
var self = this; | |
this.mainWindow = mainWindow; | |
this.nutsUrl = `${FEED_URL}/${version}`; | |
autoUpdater.on('update-available', () => { | |
console.log('[Updater] Update available'); | |
}); | |
autoUpdater.on('update-downloaded', (e, releaseNotes, releaseName) => { | |
console.log('[Updater] Update downloaded'); | |
console.log(releaseNotes); | |
// create dialog here | |
}); | |
setTimeout(() => { | |
autoUpdater.setFeedURL(self.nutsUrls) | |
self.checkForUpdates(); | |
}, ms('10s')); | |
}; | |
startCheckTimer() { | |
var self = this; | |
setInterval(() => { | |
self.checkForUpdates(); | |
}, ms('30m')); | |
}; | |
checkForUpdates() { | |
try { | |
autoUpdater.checkForUpdates() | |
} catch (ex) { | |
console.warn(`[Updater] Failure checking for updates: ${ex.message}`) | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment