import { Divider, List, Switch, TextField } from '@mui/material'; import { useEffect, useState } from 'react'; 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 Network(props: ISectionProps): React.JSX.Element { const { t } = useTranslation(); const preference = usePreferenceObservable(); const [inputUrls, setInputUrls] = useState(preference?.disableAntiAntiLeechForUrls.join('\n')); useEffect(() => { if (inputUrls === undefined && preference?.disableAntiAntiLeechForUrls !== undefined) { setInputUrls(preference.disableAntiAntiLeechForUrls.join('\n')); } }, [inputUrls, preference]); return ( <> {t('Preference.Network')} {preference === undefined ? {t('Loading')} : ( <> { await window.service.preference.set('disableAntiAntiLeech', event.target.checked); }} /> } > {!preference.disableAntiAntiLeech && ( <> ) => { setInputUrls(event.target.value); const urlList = event.target.value.split('\n').map(url => url.trim()).filter(Boolean); void window.service.preference.set('disableAntiAntiLeechForUrls', urlList); }} variant='outlined' /> )} )} ); }