mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 12:38:39 -09:00
* increase timeout for update checks It seems like, there are lots of them and GitHub is not happy. So increasing timeout 6x should fix that. In the end there is no need to check updates every 5 minutes. Fix #880 * restore check updates on start
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
const {autoUpdater} = require('electron');
|
|
const ms = require('ms');
|
|
|
|
const notify = require('./notify'); // eslint-disable-line no-unused-vars
|
|
const {version} = require('./package');
|
|
|
|
// accepted values: `osx`, `win32`
|
|
// https://nuts.gitbook.com/update-windows.html
|
|
const platform = process.platform === 'darwin' ?
|
|
'osx' :
|
|
process.platform;
|
|
const FEED_URL = `https://hyper-updates.now.sh/update/${platform}`;
|
|
let isInit = false;
|
|
|
|
function init() {
|
|
autoUpdater.on('error', (err, msg) => {
|
|
console.error('Error fetching updates', msg + ' (' + err.stack + ')');
|
|
});
|
|
|
|
autoUpdater.setFeedURL(`${FEED_URL}/${version}`);
|
|
|
|
setTimeout(() => {
|
|
autoUpdater.checkForUpdates();
|
|
}, ms('10s'));
|
|
|
|
setInterval(() => {
|
|
autoUpdater.checkForUpdates();
|
|
}, ms('30m'));
|
|
|
|
isInit = true;
|
|
}
|
|
|
|
module.exports = function (win) {
|
|
if (!isInit) {
|
|
init();
|
|
}
|
|
|
|
const {rpc} = win;
|
|
|
|
const onupdate = (ev, releaseNotes, releaseName) => {
|
|
rpc.emit('update available', {releaseNotes, releaseName});
|
|
};
|
|
|
|
autoUpdater.on('update-downloaded', onupdate);
|
|
|
|
rpc.once('quit and install', () => {
|
|
autoUpdater.quitAndInstall();
|
|
});
|
|
|
|
win.on('close', () => {
|
|
autoUpdater.removeListener('update-downloaded', onupdate);
|
|
});
|
|
};
|