mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-12 20:18:41 -09:00
Add disableAutoUpdates config option (#5805)
Co-authored-by: Labhansh Agrawal <labhansh.agrawal@gmail.com>
This commit is contained in:
parent
ee4ae5c4fe
commit
61204f8d5c
3 changed files with 27 additions and 14 deletions
|
|
@ -157,6 +157,9 @@ module.exports = {
|
||||||
// if `false` (without backticks and without quotes), Hyper will use ligatures provided by some fonts
|
// if `false` (without backticks and without quotes), Hyper will use ligatures provided by some fonts
|
||||||
disableLigatures: true,
|
disableLigatures: true,
|
||||||
|
|
||||||
|
// set to true to disable auto updates
|
||||||
|
disableAutoUpdates: false,
|
||||||
|
|
||||||
// for advanced config flags please refer to https://hyper.is/#cfg
|
// for advanced config flags please refer to https://hyper.is/#cfg
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,23 @@ const isLinux = platform === 'linux';
|
||||||
|
|
||||||
const autoUpdater: AutoUpdater = isLinux ? autoUpdaterLinux : electron.autoUpdater;
|
const autoUpdater: AutoUpdater = isLinux ? autoUpdaterLinux : electron.autoUpdater;
|
||||||
|
|
||||||
|
const getDecoratedConfigWithRetry = async () => {
|
||||||
|
return await retry(() => {
|
||||||
|
const content = getDecoratedConfig();
|
||||||
|
if (!content) {
|
||||||
|
throw new Error('No config content loaded');
|
||||||
|
}
|
||||||
|
return content;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkForUpdates = async () => {
|
||||||
|
const config = await getDecoratedConfigWithRetry();
|
||||||
|
if (!config.disableAutoUpdates) {
|
||||||
|
autoUpdater.checkForUpdates();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let isInit = false;
|
let isInit = false;
|
||||||
// Default to the "stable" update channel
|
// Default to the "stable" update channel
|
||||||
let canaryUpdates = false;
|
let canaryUpdates = false;
|
||||||
|
|
@ -46,15 +63,7 @@ async function init() {
|
||||||
console.error('Error fetching updates', `${err.message} (${err.stack})`);
|
console.error('Error fetching updates', `${err.message} (${err.stack})`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const config = await retry(() => {
|
const config = await getDecoratedConfigWithRetry();
|
||||||
const content = getDecoratedConfig();
|
|
||||||
|
|
||||||
if (!content) {
|
|
||||||
throw new Error('No config content loaded');
|
|
||||||
}
|
|
||||||
|
|
||||||
return content;
|
|
||||||
});
|
|
||||||
|
|
||||||
// If defined in the config, switch to the "canary" channel
|
// If defined in the config, switch to the "canary" channel
|
||||||
if (config.updateChannel && isCanary(config.updateChannel)) {
|
if (config.updateChannel && isCanary(config.updateChannel)) {
|
||||||
|
|
@ -66,11 +75,11 @@ async function init() {
|
||||||
autoUpdater.setFeedURL({url: feedURL});
|
autoUpdater.setFeedURL({url: feedURL});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
autoUpdater.checkForUpdates();
|
void checkForUpdates();
|
||||||
}, ms('10s'));
|
}, ms('10s'));
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
autoUpdater.checkForUpdates();
|
void checkForUpdates();
|
||||||
}, ms('30m'));
|
}, ms('30m'));
|
||||||
|
|
||||||
isInit = true;
|
isInit = true;
|
||||||
|
|
@ -103,15 +112,15 @@ export default (win: BrowserWindow) => {
|
||||||
autoUpdater.quitAndInstall();
|
autoUpdater.quitAndInstall();
|
||||||
});
|
});
|
||||||
|
|
||||||
app.config.subscribe(() => {
|
app.config.subscribe(async () => {
|
||||||
const {updateChannel} = app.plugins.getDecoratedConfig();
|
const {updateChannel} = await getDecoratedConfigWithRetry();
|
||||||
const newUpdateIsCanary = isCanary(updateChannel);
|
const newUpdateIsCanary = isCanary(updateChannel);
|
||||||
|
|
||||||
if (newUpdateIsCanary !== canaryUpdates) {
|
if (newUpdateIsCanary !== canaryUpdates) {
|
||||||
const feedURL = buildFeedUrl(newUpdateIsCanary, version);
|
const feedURL = buildFeedUrl(newUpdateIsCanary, version);
|
||||||
|
|
||||||
autoUpdater.setFeedURL({url: feedURL});
|
autoUpdater.setFeedURL({url: feedURL});
|
||||||
autoUpdater.checkForUpdates();
|
void checkForUpdates();
|
||||||
|
|
||||||
canaryUpdates = newUpdateIsCanary;
|
canaryUpdates = newUpdateIsCanary;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
lib/config.d.ts
vendored
1
lib/config.d.ts
vendored
|
|
@ -34,6 +34,7 @@ export type configOptions = {
|
||||||
cursorColor: string;
|
cursorColor: string;
|
||||||
cursorShape: 'BEAM' | 'UNDERLINE' | 'BLOCK';
|
cursorShape: 'BEAM' | 'UNDERLINE' | 'BLOCK';
|
||||||
defaultSSHApp: boolean;
|
defaultSSHApp: boolean;
|
||||||
|
disableAutoUpdates: boolean;
|
||||||
disableLigatures: boolean;
|
disableLigatures: boolean;
|
||||||
env: Record<string, string>;
|
env: Record<string, string>;
|
||||||
fontFamily: string;
|
fontFamily: string;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue