mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Adding in ability to switch release channel without restarting Hyper (#2408)
This commit is contained in:
parent
5d0c6355e1
commit
5227486916
1 changed files with 26 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
// Packages
|
// Packages
|
||||||
const {autoUpdater} = require('electron');
|
const {autoUpdater, app} = require('electron');
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
const retry = require('async-retry');
|
const retry = require('async-retry');
|
||||||
|
|
||||||
|
|
@ -12,6 +12,15 @@ const {getConfig} = require('./config');
|
||||||
const {platform} = process;
|
const {platform} = process;
|
||||||
|
|
||||||
let isInit = false;
|
let isInit = false;
|
||||||
|
// Default to the "stable" update channel
|
||||||
|
let canaryUpdates = false;
|
||||||
|
|
||||||
|
const buildFeedUrl = canary => {
|
||||||
|
const updatePrefix = canary ? 'releases-canary' : 'releases';
|
||||||
|
return `https://${updatePrefix}.hyper.is/update/${platform}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isCanary = updateChannel => updateChannel === 'canary';
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
autoUpdater.on('error', (err, msg) => {
|
autoUpdater.on('error', (err, msg) => {
|
||||||
|
|
@ -29,16 +38,12 @@ async function init() {
|
||||||
return content;
|
return content;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Default to the "stable" update channel
|
|
||||||
let canaryUpdates = false;
|
|
||||||
|
|
||||||
// If defined in the config, switch to the "canary" channel
|
// If defined in the config, switch to the "canary" channel
|
||||||
if (config.updateChannel && config.updateChannel === 'canary') {
|
if (config.updateChannel && isCanary(config.updateChannel)) {
|
||||||
canaryUpdates = true;
|
canaryUpdates = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const updatePrefix = canaryUpdates ? 'releases-canary' : 'releases';
|
const feedURL = buildFeedUrl(canaryUpdates);
|
||||||
const feedURL = `https://${updatePrefix}.hyper.is/update/${platform}`;
|
|
||||||
|
|
||||||
autoUpdater.setFeedURL(`${feedURL}/${version}`);
|
autoUpdater.setFeedURL(`${feedURL}/${version}`);
|
||||||
|
|
||||||
|
|
@ -70,6 +75,20 @@ module.exports = win => {
|
||||||
autoUpdater.quitAndInstall();
|
autoUpdater.quitAndInstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.config.subscribe(() => {
|
||||||
|
const {updateChannel} = app.plugins.getDecoratedConfig();
|
||||||
|
const newUpdateIsCanary = isCanary(updateChannel);
|
||||||
|
|
||||||
|
if (newUpdateIsCanary !== canaryUpdates) {
|
||||||
|
const feedURL = buildFeedUrl(newUpdateIsCanary);
|
||||||
|
|
||||||
|
autoUpdater.setFeedURL(`${feedURL}/${version}`);
|
||||||
|
autoUpdater.checkForUpdates();
|
||||||
|
|
||||||
|
canaryUpdates = newUpdateIsCanary;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
win.on('close', () => {
|
win.on('close', () => {
|
||||||
autoUpdater.removeListener('update-downloaded', onupdate);
|
autoUpdater.removeListener('update-downloaded', onupdate);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue