Skip to content

Instantly share code, notes, and snippets.

@weedgrease
Created February 22, 2017 22:24
Show Gist options
  • Save weedgrease/bf5fc9191cbfaeb8ca9325d587b4dce9 to your computer and use it in GitHub Desktop.
Save weedgrease/bf5fc9191cbfaeb8ca9325d587b4dce9 to your computer and use it in GitHub Desktop.
const {app, autoUpdater, ipcMain, ipcRenderer} = 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 Updater {
static remoteQuitAndInstall() {
ipcRenderer.send('quitAndInstall');
};
constructor(store, mainWindow) {
var self = this;
this.mainWindow = mainWindow;
this.nutsUrl = `${FEED_URL}/${version}`;
autoUpdater.on('update-downloaded', e => {
// create dialog here
});
setTimeout(() => {
autoUpdater.setFeedURL(self.nutsUrls)
self.checkForUpdates();
}, ms('10s'));
};
startCheckTimer() {
var self = this;
setInterval(() => {
self.checkForUpdates();
}, ms('30m'));
};
checkForUpdates() {
autoUpdater.checkForUpdates()
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment