bugfix
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { FileUpload } from '@mui/icons-material'
|
import { FileUpload } from '@mui/icons-material'
|
||||||
import CloseIcon from '@mui/icons-material/Close'
|
import CloseIcon from '@mui/icons-material/Close'
|
||||||
import {
|
import {
|
||||||
|
Backdrop,
|
||||||
Button,
|
Button,
|
||||||
Container,
|
Container,
|
||||||
FormControl,
|
FormControl,
|
||||||
@@ -21,7 +22,7 @@ import Toolbar from '@mui/material/Toolbar'
|
|||||||
import { TransitionProps } from '@mui/material/transitions'
|
import { TransitionProps } from '@mui/material/transitions'
|
||||||
import Typography from '@mui/material/Typography'
|
import Typography from '@mui/material/Typography'
|
||||||
import { Buffer } from 'buffer'
|
import { Buffer } from 'buffer'
|
||||||
import { forwardRef, useContext, useEffect, useMemo, useRef, useState } from 'react'
|
import { forwardRef, useContext, useEffect, useMemo, useRef, useState, useTransition } from 'react'
|
||||||
import { useDispatch, useSelector } from 'react-redux'
|
import { useDispatch, useSelector } from 'react-redux'
|
||||||
import FormatsGrid from '../components/FormatsGrid'
|
import FormatsGrid from '../components/FormatsGrid'
|
||||||
import { CliArguments } from '../lib/argsParser'
|
import { CliArguments } from '../lib/argsParser'
|
||||||
@@ -30,6 +31,7 @@ import { RPCClientContext } from '../providers/rpcClientProvider'
|
|||||||
import { RootState } from '../stores/store'
|
import { RootState } from '../stores/store'
|
||||||
import type { DLMetadata } from '../types'
|
import type { DLMetadata } from '../types'
|
||||||
import { isValidURL, toFormatArgs } from '../utils'
|
import { isValidURL, toFormatArgs } from '../utils'
|
||||||
|
import { isPending } from '@reduxjs/toolkit'
|
||||||
|
|
||||||
const Transition = forwardRef(function Transition(
|
const Transition = forwardRef(function Transition(
|
||||||
props: TransitionProps & {
|
props: TransitionProps & {
|
||||||
@@ -43,9 +45,14 @@ const Transition = forwardRef(function Transition(
|
|||||||
type Props = {
|
type Props = {
|
||||||
open: boolean
|
open: boolean
|
||||||
onClose: () => void
|
onClose: () => void
|
||||||
|
onDownloadStart: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function DownloadDialog({ open, onClose }: Props) {
|
export default function DownloadDialog({
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
|
onDownloadStart
|
||||||
|
}: Props) {
|
||||||
// redux state
|
// redux state
|
||||||
const settings = useSelector((state: RootState) => state.settings)
|
const settings = useSelector((state: RootState) => state.settings)
|
||||||
const status = useSelector((state: RootState) => state.status)
|
const status = useSelector((state: RootState) => state.status)
|
||||||
@@ -90,9 +97,12 @@ export default function DownloadDialog({ open, onClose }: Props) {
|
|||||||
setFilenameOverride(localStorage.getItem('last-filename-override') ?? '')
|
setFilenameOverride(localStorage.getItem('last-filename-override') ?? '')
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
// transitions
|
||||||
|
const [isPending, startTransition] = useTransition()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrive url from input, cli-arguments from checkboxes and emits via WebSocket
|
* Retrive url from input, cli-arguments from checkboxes and emits via WebSocket
|
||||||
*/
|
*/
|
||||||
const sendUrl = (immediate?: string) => {
|
const sendUrl = (immediate?: string) => {
|
||||||
const codes = new Array<string>()
|
const codes = new Array<string>()
|
||||||
if (pickedVideoFormat !== '') codes.push(pickedVideoFormat)
|
if (pickedVideoFormat !== '') codes.push(pickedVideoFormat)
|
||||||
@@ -112,7 +122,7 @@ export default function DownloadDialog({ open, onClose }: Props) {
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
resetInput()
|
resetInput()
|
||||||
setDownloadFormats(undefined)
|
setDownloadFormats(undefined)
|
||||||
onClose()
|
onDownloadStart()
|
||||||
}, 250)
|
}, 250)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +205,10 @@ export default function DownloadDialog({ open, onClose }: Props) {
|
|||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
TransitionComponent={Transition}
|
TransitionComponent={Transition}
|
||||||
>
|
>
|
||||||
|
<Backdrop
|
||||||
|
sx={{ color: '#fff', zIndex: (theme) => theme.zIndex.drawer + 1 }}
|
||||||
|
open={isPending}
|
||||||
|
/>
|
||||||
<AppBar sx={{ position: 'relative' }}>
|
<AppBar sx={{ position: 'relative' }}>
|
||||||
<Toolbar>
|
<Toolbar>
|
||||||
<IconButton
|
<IconButton
|
||||||
@@ -295,7 +309,10 @@ export default function DownloadDialog({ open, onClose }: Props) {
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
disabled={url === ''}
|
disabled={url === ''}
|
||||||
onClick={() => settings.formatSelection ? sendUrlFormatSelection() : sendUrl()}
|
onClick={() => settings.formatSelection
|
||||||
|
? startTransition(() => sendUrlFormatSelection())
|
||||||
|
: sendUrl()
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{settings.formatSelection ? i18n.t('selectFormatButton') : i18n.t('startButton')}
|
{settings.formatSelection ? i18n.t('selectFormatButton') : i18n.t('startButton')}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ export default function Home() {
|
|||||||
if (activeDownloads && activeDownloads.length >= 0) {
|
if (activeDownloads && activeDownloads.length >= 0) {
|
||||||
setShowBackdrop(false)
|
setShowBackdrop(false)
|
||||||
}
|
}
|
||||||
}, [activeDownloads])
|
}, [activeDownloads?.length])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abort a specific download if id's provided, other wise abort all running ones.
|
* Abort a specific download if id's provided, other wise abort all running ones.
|
||||||
@@ -165,12 +165,17 @@ export default function Home() {
|
|||||||
onClick={() => setOpenDialog(true)}
|
onClick={() => setOpenDialog(true)}
|
||||||
/>
|
/>
|
||||||
</SpeedDial>
|
</SpeedDial>
|
||||||
<DownloadDialog open={openDialog} onClose={() => {
|
<DownloadDialog
|
||||||
setOpenDialog(false)
|
open={openDialog}
|
||||||
activeDownloads?.length === 0
|
onClose={() => {
|
||||||
? setShowBackdrop(false)
|
setOpenDialog(false)
|
||||||
: setShowBackdrop(true)
|
setShowBackdrop(false)
|
||||||
}} />
|
}}
|
||||||
|
onDownloadStart={() => {
|
||||||
|
setOpenDialog(false)
|
||||||
|
setShowBackdrop(true)
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user