From d497bf2cccdb60b99578ee51be804a6ba6c00356 Mon Sep 17 00:00:00 2001 From: Muhammad Farhan Date: Fri, 28 Mar 2025 12:23:42 +0500 Subject: [PATCH] fix: update useRef before dispatching file upload action --- src/files-and-videos/videos-page/VideosPage.jsx | 14 ++++++++++++++ src/files-and-videos/videos-page/data/thunks.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/files-and-videos/videos-page/VideosPage.jsx b/src/files-and-videos/videos-page/VideosPage.jsx index bf1f78528..d82c45692 100644 --- a/src/files-and-videos/videos-page/VideosPage.jsx +++ b/src/files-and-videos/videos-page/VideosPage.jsx @@ -29,6 +29,7 @@ import { resetErrors, updateVideoOrder, cancelAllUploads, + newUploadData, } from './data/thunks'; import messages from './messages'; import VideosPageProvider from './VideosPageProvider'; @@ -124,6 +125,19 @@ const VideosPage = ({ const handleAddFile = (files) => { handleErrorReset({ errorType: 'add' }); uploadingIdsRef.current.uploadCount = files.length; + + files.forEach((file, idx) => { + const name = file?.name || `Video ${idx + 1}`; + const progress = 0; + + newUploadData({ + status: RequestStatus.PENDING, + currentData: uploadingIdsRef.current.uploadData, + originalValue: { name, progress }, + key: `video_${idx}`, + }); + }); + dispatch(addVideoFile(courseId, files, videoIds, uploadingIdsRef)); }; const handleDeleteFile = (id) => dispatch(deleteVideoFile(courseId, id)); diff --git a/src/files-and-videos/videos-page/data/thunks.js b/src/files-and-videos/videos-page/data/thunks.js index cefc04ebd..1e682d734 100644 --- a/src/files-and-videos/videos-page/data/thunks.js +++ b/src/files-and-videos/videos-page/data/thunks.js @@ -280,7 +280,7 @@ const uploadToBucket = async ({ } }; -const newUploadData = ({ +export const newUploadData = ({ status, edxVideoId, currentData,