diff --git a/src/main/main.ts b/src/main/main.ts index cfa77ae5..1dee3ab0 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -295,9 +295,10 @@ const createWindow = async () => { return { action: 'deny' }; }); - // Remove this if your app does not use auto updates - // eslint-disable-next-line - new AppUpdater(); + if (store.get('disable_auto_updates') !== true) { + // eslint-disable-next-line + new AppUpdater(); + } }; app.commandLine.appendSwitch('disable-features', 'HardwareMediaKeyHandling,MediaSessionService'); diff --git a/src/renderer/features/settings/components/window/update-settings.tsx b/src/renderer/features/settings/components/window/update-settings.tsx new file mode 100644 index 00000000..f02bd0ab --- /dev/null +++ b/src/renderer/features/settings/components/window/update-settings.tsx @@ -0,0 +1,41 @@ +import isElectron from 'is-electron'; +import { useWindowSettings, useSettingsStoreActions } from '../../../../store/settings.store'; +import { + SettingsSection, + SettingOption, +} from '/@/renderer/features/settings/components/settings-section'; +import { Switch } from '/@/renderer/components'; + +const localSettings = isElectron() ? window.electron.localSettings : null; + +export const UpdateSettings = () => { + const settings = useWindowSettings(); + const { setSettings } = useSettingsStoreActions(); + + const updateOptions: SettingOption[] = [ + { + control: ( + { + if (!e) return; + localSettings?.set('disable_auto_updates', e.currentTarget.checked); + setSettings({ + window: { + ...settings, + disableAutoUpdate: e.currentTarget.checked, + }, + }); + }} + /> + ), + description: 'Enabling this option will disable checking for new versions on startup', + isHidden: !isElectron(), + title: 'Disable automatic updates', + }, + ]; + + return ; +}; diff --git a/src/renderer/features/settings/components/window/window-tab.tsx b/src/renderer/features/settings/components/window/window-tab.tsx index b99b938c..c191842c 100644 --- a/src/renderer/features/settings/components/window/window-tab.tsx +++ b/src/renderer/features/settings/components/window/window-tab.tsx @@ -1,10 +1,13 @@ -import { Stack } from '@mantine/core'; -import { WindowSettings } from './window-settings'; +import { Divider, Stack } from '@mantine/core'; +import { UpdateSettings } from '/@/renderer/features/settings/components/window/update-settings'; +import { WindowSettings } from '/@/renderer/features/settings/components/window/window-settings'; export const WindowTab = () => { return ( + + ); }; diff --git a/src/renderer/store/index.ts b/src/renderer/store/index.ts index d41850d1..61a484fd 100644 --- a/src/renderer/store/index.ts +++ b/src/renderer/store/index.ts @@ -6,3 +6,4 @@ export * from './playlist.store'; export * from './album-list-data.store'; export * from './album-artist-list-data.store'; export * from './full-screen-player.store'; +export * from './settings.store'; diff --git a/src/renderer/store/settings.store.ts b/src/renderer/store/settings.store.ts index aa19a448..42520641 100644 --- a/src/renderer/store/settings.store.ts +++ b/src/renderer/store/settings.store.ts @@ -71,6 +71,7 @@ export interface SettingsState { songs: DataTableProps; }; window: { + disableAutoUpdate: boolean; exitToTray: boolean; minimizeToTray: boolean; windowBarStyle: Platform; @@ -245,6 +246,7 @@ export const useSettingsStore = create()( }, }, window: { + disableAutoUpdate: true, exitToTray: false, minimizeToTray: false, windowBarStyle: Platform.WEB,