mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
refactor
This commit is contained in:
@@ -107,7 +107,7 @@ export default function AddDialog({ handleClose }) {
|
||||
[isUserInteractedWithPoster],
|
||||
)
|
||||
|
||||
const delayedPosterSearch = useMemo(() => debounce(posterSearch, 2700), [posterSearch])
|
||||
const delayedPosterSearch = useMemo(() => debounce(posterSearch, 700), [posterSearch])
|
||||
|
||||
const prevTitleState = usePreviousState(title)
|
||||
const prevTorrentSourceState = usePreviousState(torrentSource)
|
||||
@@ -117,7 +117,7 @@ export default function AddDialog({ handleClose }) {
|
||||
const torrentSourceChanged = torrentSource !== prevTorrentSourceState
|
||||
|
||||
const isCorrectSource = chechTorrentSource(torrentSource)
|
||||
if (!isCorrectSource) return
|
||||
if (!isCorrectSource) return setIsTorrentSourceCorrect(false)
|
||||
|
||||
setIsTorrentSourceCorrect(true)
|
||||
|
||||
@@ -144,12 +144,17 @@ export default function AddDialog({ handleClose }) {
|
||||
}
|
||||
}, [title, prevTitleState, delayedPosterSearch, posterSearch, posterSearchLanguage, skipDebounce])
|
||||
|
||||
const removePoster = () => {
|
||||
setIsPosterUrlCorrect(false)
|
||||
setPosterUrl('')
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedFile && !torrentSource) {
|
||||
setTitle('')
|
||||
setPosterUrl('')
|
||||
setPosterList()
|
||||
setIsPosterUrlCorrect(false)
|
||||
removePoster()
|
||||
setIsUserInteractedWithPoster(false)
|
||||
}
|
||||
}, [selectedFile, torrentSource])
|
||||
|
||||
@@ -164,11 +169,6 @@ export default function AddDialog({ handleClose }) {
|
||||
|
||||
const { getRootProps, getInputProps, isDragActive } = useDropzone({ onDrop: handleCapture, accept: '.torrent' })
|
||||
|
||||
const removePoster = () => {
|
||||
setIsPosterUrlCorrect(false)
|
||||
setPosterUrl('')
|
||||
}
|
||||
|
||||
const handleTorrentSourceChange = ({ target: { value } }) => setTorrentSource(value)
|
||||
const handleTitleChange = ({ target: { value } }) => setTitle(value)
|
||||
const handlePosterUrlChange = ({ target: { value } }) => {
|
||||
@@ -261,8 +261,7 @@ export default function AddDialog({ handleClose }) {
|
||||
</LeftSide>
|
||||
|
||||
<RightSide>
|
||||
{/* <RightSideContainer isHidden={!isTorrentSourceCorrect}> */}
|
||||
<RightSideContainer isHidden={false}>
|
||||
<RightSideContainer isHidden={!isTorrentSourceCorrect}>
|
||||
<TextField
|
||||
onChange={handleTitleChange}
|
||||
value={title}
|
||||
@@ -332,8 +331,7 @@ export default function AddDialog({ handleClose }) {
|
||||
notificationMessage={
|
||||
!torrentSource ? t('AddTorrentSourceNotification') : !isTorrentSourceCorrect && t('WrongTorrentSource')
|
||||
}
|
||||
// isHidden={isTorrentSourceCorrect}
|
||||
isHidden
|
||||
isHidden={isTorrentSourceCorrect}
|
||||
/>
|
||||
</RightSide>
|
||||
</Content>
|
||||
|
||||
Reference in New Issue
Block a user