feishin/src/renderer/features/settings/components/window/update-settings.tsx

53 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-03-31 05:42:48 -07:00
import isElectron from 'is-electron';
import { useTranslation } from 'react-i18next';
2023-03-31 05:42:48 -07:00
import { useWindowSettings, useSettingsStoreActions } from '../../../../store/settings.store';
import {
2023-07-01 19:10:05 -07:00
SettingsSection,
SettingOption,
2023-03-31 05:42:48 -07:00
} from '/@/renderer/features/settings/components/settings-section';
import { Switch } from '/@/renderer/components';
const localSettings = isElectron() ? window.electron.localSettings : null;
const utils = isElectron() ? window.electron.utils : null;
2023-03-31 05:42:48 -07:00
export const UpdateSettings = () => {
const { t } = useTranslation();
2023-07-01 19:10:05 -07:00
const settings = useWindowSettings();
const { setSettings } = useSettingsStoreActions();
2023-03-31 05:42:48 -07:00
2023-07-01 19:10:05 -07:00
const updateOptions: SettingOption[] = [
{
control: (
<Switch
aria-label="Disable automatic updates"
defaultChecked={settings.disableAutoUpdate}
disabled={!isElectron()}
onChange={(e) => {
if (!e) return;
localSettings?.set('disable_auto_updates', e.currentTarget.checked);
setSettings({
window: {
...settings,
disableAutoUpdate: e.currentTarget.checked,
},
});
}}
/>
),
description: t('setting.disableAutomaticUpdates', {
context: 'description',
postProcess: 'sentenceCase',
}),
2023-07-01 19:10:05 -07:00
isHidden: !isElectron(),
title: t('setting.disableAutomaticUpdates', { postProcess: 'sentenceCase' }),
2023-07-01 19:10:05 -07:00
},
];
2023-03-31 05:42:48 -07:00
return (
<SettingsSection
divider={utils?.isLinux()}
options={updateOptions}
/>
);
2023-03-31 05:42:48 -07:00
};