From 9397ba64b4a129a9a900008f3db0280360894190 Mon Sep 17 00:00:00 2001 From: andreidekterev Date: Thu, 3 Aug 2023 14:33:55 +0700 Subject: [PATCH] fix(#168): add isDownloaded state --- .../MatchPage/components/MatchDownloadPopup/index.tsx | 1 + .../components/MatchDownloadButton/index.tsx | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/features/MatchPage/components/MatchDownloadPopup/index.tsx b/src/features/MatchPage/components/MatchDownloadPopup/index.tsx index ac121b9b..b0a0ac63 100644 --- a/src/features/MatchPage/components/MatchDownloadPopup/index.tsx +++ b/src/features/MatchPage/components/MatchDownloadPopup/index.tsx @@ -74,6 +74,7 @@ export const MatchDownloadPopup = ({ config.concat = fileType.download_single_file === id } + setPlaylistConfig(config) refetch() closePopup() openDownloadNotification() diff --git a/src/features/MatchSidePlaylists/components/MatchDownloadButton/index.tsx b/src/features/MatchSidePlaylists/components/MatchDownloadButton/index.tsx index 7fedbf8e..666758a8 100644 --- a/src/features/MatchSidePlaylists/components/MatchDownloadButton/index.tsx +++ b/src/features/MatchSidePlaylists/components/MatchDownloadButton/index.tsx @@ -35,7 +35,7 @@ export const MatchDownloadButton = ({ const { profile } = useMatchPageStore() const { sportType } = usePageParams() const [playlistConfig, setPlaylistConfig] = useState(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') {