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],
|
[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>
|
||||||
|
|||||||
Reference in New Issue
Block a user