diff --git a/src/main/index.ts b/src/main/index.ts index a9bb70c9f..8335615d0 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -30,6 +30,7 @@ import MenuBuilder from './menu'; import { autoUpdaterLogInterface, createLog, + disableAutoUpdates, hotkeyToElectronAccelerator, isLinux, isMacOS, @@ -456,7 +457,7 @@ async function createWindow(first = true): Promise { return { action: 'deny' }; }); - if (store.get('disable_auto_updates') !== true) { + if (!disableAutoUpdates() && store.get('disable_auto_updates') !== true) { new AppUpdater(); } diff --git a/src/main/utils.ts b/src/main/utils.ts index fe5ea808d..3a189324c 100644 --- a/src/main/utils.ts +++ b/src/main/utils.ts @@ -18,6 +18,10 @@ if (process.env.NODE_ENV === 'development') { }; } +export const disableAutoUpdates = () => { + return process.env['DISABLE_AUTO_UPDATES']; +}; + export const isMacOS = () => { return process.platform === 'darwin'; }; diff --git a/src/preload/utils.ts b/src/preload/utils.ts index e8f0315a6..f7c4228a3 100644 --- a/src/preload/utils.ts +++ b/src/preload/utils.ts @@ -1,6 +1,6 @@ import { ipcRenderer, IpcRendererEvent } from 'electron'; -import { isLinux, isMacOS, isWindows } from '../main/utils'; +import { disableAutoUpdates, isLinux, isMacOS, isWindows } from '../main/utils'; const openItem = async (path: string) => { return ipcRenderer.invoke('open-item', path); @@ -40,6 +40,7 @@ const download = (url: string) => { }; export const utils = { + disableAutoUpdates, download, isLinux, isMacOS, diff --git a/src/renderer/features/settings/components/window/update-settings.tsx b/src/renderer/features/settings/components/window/update-settings.tsx index cc10a35b3..8cc624f93 100644 --- a/src/renderer/features/settings/components/window/update-settings.tsx +++ b/src/renderer/features/settings/components/window/update-settings.tsx @@ -10,6 +10,11 @@ import { Select } from '/@/shared/components/select/select'; import { Switch } from '/@/shared/components/switch/switch'; const localSettings = isElectron() ? window.api.localSettings : null; +const utils = isElectron() ? window.api.utils : null; + +function disableAutoUpdates(): boolean { + return !isElectron() || utils?.disableAutoUpdates(); +} export const UpdateSettings = () => { const { t } = useTranslation(); @@ -55,7 +60,7 @@ export const UpdateSettings = () => { context: 'description', postProcess: 'sentenceCase', }), - isHidden: !isElectron(), + isHidden: disableAutoUpdates(), title: t('setting.releaseChannel', { postProcess: 'sentenceCase' }), }, { @@ -63,7 +68,7 @@ export const UpdateSettings = () => { { if (!e) return; localSettings?.set('disable_auto_updates', e.currentTarget.checked); @@ -80,7 +85,7 @@ export const UpdateSettings = () => { context: 'description', postProcess: 'sentenceCase', }), - isHidden: !isElectron(), + isHidden: disableAutoUpdates(), title: t('setting.disableAutomaticUpdates', { postProcess: 'sentenceCase' }), }, ];