import ChevronRightIcon from '@mui/icons-material/ChevronRight'; import { Divider, List, ListItemButton, Switch } from '@mui/material'; import { useTranslation } from 'react-i18next'; import { ListItem, ListItemText } from '@/components/ListItem'; import { usePreferenceObservable } from '@services/preferences/hooks'; import { Paper, SectionTitle } from '../PreferenceComponents'; import type { ISectionProps } from '../useSections'; export function Downloads(props: Required): React.JSX.Element { const { t } = useTranslation(); const preference = usePreferenceObservable(); return ( <> {t('Preference.Downloads')} {preference === undefined ? {t('Loading')} : ( <> { window.service.native .pickDirectory(preference.downloadPath) .then(async (filePaths) => { if (filePaths.length > 0) { await window.service.preference.set('downloadPath', filePaths[0]); } }) .catch((error: unknown) => { void window.service.native.log('error', 'Preferences: pickDirectory failed', { function: 'Downloads.pickDirectory', error }); }); }} > { await window.service.preference.set('askForDownloadPath', event.target.checked); }} /> } > )} ); }