This commit is contained in:
Daniel Shleifman
2021-06-10 23:06:49 +03:00
parent b53648afa4
commit 1c8b5f7447

View File

@@ -107,7 +107,7 @@ export default function AddDialog({ handleClose }) {
[isUserInteractedWithPoster], [isUserInteractedWithPoster],
) )
const delayedPosterSearch = useMemo(() => debounce(posterSearch, 2700), [posterSearch]) const delayedPosterSearch = useMemo(() => debounce(posterSearch, 700), [posterSearch])
const prevTitleState = usePreviousState(title) const prevTitleState = usePreviousState(title)
const prevTorrentSourceState = usePreviousState(torrentSource) const prevTorrentSourceState = usePreviousState(torrentSource)
@@ -117,7 +117,7 @@ export default function AddDialog({ handleClose }) {
const torrentSourceChanged = torrentSource !== prevTorrentSourceState const torrentSourceChanged = torrentSource !== prevTorrentSourceState
const isCorrectSource = chechTorrentSource(torrentSource) const isCorrectSource = chechTorrentSource(torrentSource)
if (!isCorrectSource) return if (!isCorrectSource) return setIsTorrentSourceCorrect(false)
setIsTorrentSourceCorrect(true) setIsTorrentSourceCorrect(true)
@@ -144,12 +144,17 @@ export default function AddDialog({ handleClose }) {
} }
}, [title, prevTitleState, delayedPosterSearch, posterSearch, posterSearchLanguage, skipDebounce]) }, [title, prevTitleState, delayedPosterSearch, posterSearch, posterSearchLanguage, skipDebounce])
const removePoster = () => {
setIsPosterUrlCorrect(false)
setPosterUrl('')
}
useEffect(() => { useEffect(() => {
if (!selectedFile && !torrentSource) { if (!selectedFile && !torrentSource) {
setTitle('') setTitle('')
setPosterUrl('')
setPosterList() setPosterList()
setIsPosterUrlCorrect(false) removePoster()
setIsUserInteractedWithPoster(false)
} }
}, [selectedFile, torrentSource]) }, [selectedFile, torrentSource])
@@ -164,11 +169,6 @@ export default function AddDialog({ handleClose }) {
const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop: handleCapture, accept: '.torrent' }) const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop: handleCapture, accept: '.torrent' })
const removePoster = () => {
setIsPosterUrlCorrect(false)
setPosterUrl('')
}
const handleTorrentSourceChange = ({ target: { value } }) => setTorrentSource(value) const handleTorrentSourceChange = ({ target: { value } }) => setTorrentSource(value)
const handleTitleChange = ({ target: { value } }) => setTitle(value) const handleTitleChange = ({ target: { value } }) => setTitle(value)
const handlePosterUrlChange = ({ target: { value } }) => { const handlePosterUrlChange = ({ target: { value } }) => {
@@ -261,8 +261,7 @@ export default function AddDialog({ handleClose }) {
</LeftSide> </LeftSide>
<RightSide> <RightSide>
{/* <RightSideContainer isHidden={!isTorrentSourceCorrect}> */} <RightSideContainer isHidden={!isTorrentSourceCorrect}>
<RightSideContainer isHidden={false}>
<TextField <TextField
onChange={handleTitleChange} onChange={handleTitleChange}
value={title} value={title}
@@ -332,8 +331,7 @@ export default function AddDialog({ handleClose }) {
notificationMessage={ notificationMessage={
!torrentSource ? t('AddTorrentSourceNotification') : !isTorrentSourceCorrect && t('WrongTorrentSource') !torrentSource ? t('AddTorrentSourceNotification') : !isTorrentSourceCorrect && t('WrongTorrentSource')
} }
// isHidden={isTorrentSourceCorrect} isHidden={isTorrentSourceCorrect}
isHidden
/> />
</RightSide> </RightSide>
</Content> </Content>