fix(#168): add isDownloaded state

VID-168-donwload-video
andreidekterev 2 years ago
parent b1f82cd1b5
commit 9397ba64b4
  1. 1
      src/features/MatchPage/components/MatchDownloadPopup/index.tsx
  2. 9
      src/features/MatchSidePlaylists/components/MatchDownloadButton/index.tsx

@ -74,6 +74,7 @@ export const MatchDownloadPopup = ({
config.concat = fileType.download_single_file === id
}
setPlaylistConfig(config)
refetch()
closePopup()
openDownloadNotification()

@ -35,7 +35,7 @@ export const MatchDownloadButton = ({
const { profile } = useMatchPageStore()
const { sportType } = usePageParams()
const [playlistConfig, setPlaylistConfig] = useState<DownloadPlaylistProps | null>(null)
const [isDownloaded, setIsDownloaded] = useState(false)
const {
close,
isOpen,
@ -82,8 +82,13 @@ export const MatchDownloadButton = ({
useEffect(() => {
if (!data) return undefined
if (data?.status === 'COMPLETED' && data.urls) {
if (
data?.status === 'COMPLETED'
&& data.urls
&& !isDownloaded) {
downloadFile(data.urls)
setIsDownloaded(true)
closeDownloadNotification()
stop()
} else if (data?.status === 'ERROR') {

Loading…
Cancel
Save