Skip to content
Snippets Groups Projects
Commit a6340e1d authored by Simon Künzel's avatar Simon Künzel
Browse files

Clear download status on changes and allow unselecting a lecture

parent 8e0343bf
No related branches found
No related tags found
No related merge requests found
...@@ -296,7 +296,7 @@ function DownloadAllLectureListItem({ ...@@ -296,7 +296,7 @@ function DownloadAllLectureListItem({
}: { }: {
lecture: lecture; lecture: lecture;
selectedMediumId: int | undefined; selectedMediumId: int | undefined;
setSelectedMediumId: (mediumId: int) => void; setSelectedMediumId: (mediumId: int | undefined) => void;
isDownloading: boolean; isDownloading: boolean;
downloadStatus: DownloadStatus | undefined; downloadStatus: DownloadStatus | undefined;
}) { }) {
...@@ -369,7 +369,9 @@ function DownloadAllLectureListItem({ ...@@ -369,7 +369,9 @@ function DownloadAllLectureListItem({
className="form-check-input" className="form-check-input"
checked={selectedMediumId !== undefined} checked={selectedMediumId !== undefined}
disabled={isDownloading || media.length == 0} disabled={isDownloading || media.length == 0}
onChange={(e) => setSelectedMediumId(media[0].id)} onChange={(e) =>
setSelectedMediumId(e.target.checked ? media[0].id : undefined)
}
/> />
</td> </td>
<td <td
...@@ -461,17 +463,24 @@ export default function DownloadAllModal({ course }: { course: course }) { ...@@ -461,17 +463,24 @@ export default function DownloadAllModal({ course }: { course: course }) {
if (publishMedia.length > 0) newChosenMedia.set(lecture.id, publishMedia[0].id); if (publishMedia.length > 0) newChosenMedia.set(lecture.id, publishMedia[0].id);
} }
setChosenMediumIdByLectureId(newChosenMedia); setChosenMediumIdByLectureId(newChosenMedia);
setDownloadStatus(undefined);
}; };
const selectNone = () => { const selectNone = () => {
if (isDownloading) return; if (isDownloading) return;
setChosenMediumIdByLectureId(new Map()); setChosenMediumIdByLectureId(new Map());
setDownloadStatus(undefined);
}; };
const setLectureToMediumId = (lecture_id: int, medium_id: int) => { const setLectureToMediumId = (lecture_id: int, medium_id: int | undefined) => {
if (isDownloading) return; if (isDownloading) return;
const newChosenMedia = new Map(chosenMediumIdByLectureId); const newChosenMedia = new Map(chosenMediumIdByLectureId);
if (medium_id !== undefined) {
newChosenMedia.set(lecture_id, medium_id); newChosenMedia.set(lecture_id, medium_id);
} else {
newChosenMedia.delete(lecture_id);
}
setChosenMediumIdByLectureId(newChosenMedia); setChosenMediumIdByLectureId(newChosenMedia);
setDownloadStatus(undefined);
}; };
const setAllToQuality = (qualityToSet: string) => { const setAllToQuality = (qualityToSet: string) => {
if (isDownloading) return; if (isDownloading) return;
...@@ -485,6 +494,7 @@ export default function DownloadAllModal({ course }: { course: course }) { ...@@ -485,6 +494,7 @@ export default function DownloadAllModal({ course }: { course: course }) {
} }
} }
setChosenMediumIdByLectureId(newChosenMedia); setChosenMediumIdByLectureId(newChosenMedia);
setDownloadStatus(undefined);
}; };
const startDownloads = async () => { const startDownloads = async () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment