diff --git a/enjoy/src/renderer/components/videos/ted-talks-segment.tsx b/enjoy/src/renderer/components/videos/ted-talks-segment.tsx index 186877b5..604f2d2a 100644 --- a/enjoy/src/renderer/components/videos/ted-talks-segment.tsx +++ b/enjoy/src/renderer/components/videos/ted-talks-segment.tsx @@ -1,3 +1,5 @@ +/** @format */ + import { useState, useEffect, useContext } from "react"; import { AppSettingsProviderContext } from "@renderer/context"; import { @@ -16,24 +18,30 @@ import { useNavigate } from "react-router-dom"; import { LoaderIcon } from "lucide-react"; import { secondsToTimestamp } from "@renderer/lib/utils"; +enum DownloadType { + audio = "audio", + video = "video", +} export const TedTalksSegment = () => { const navigate = useNavigate(); const { EnjoyApp } = useContext(AppSettingsProviderContext); const [talks, setTalks] = useState([]); const [selectedTalk, setSelectedTalk] = useState(null); const [submitting, setSubmitting] = useState(false); + const [submittingType, setSubmittingType] = useState(); const [downloadUrl, setDownloadUrl] = useState<{ audio: string; video: string; }>(); - const addToLibrary = (type: "audio" | "video") => { + const addToLibrary = (type: DownloadType) => { if (!downloadUrl) return; if (!selectedTalk) return; let url = downloadUrl.audio; - if (type === "video") url = downloadUrl.video; + if (type === DownloadType.video) url = downloadUrl.video; setSubmitting(true); + setSubmittingType(type); EnjoyApp.videos .create(url, { @@ -49,6 +57,7 @@ export const TedTalksSegment = () => { }) .finally(() => { setSubmitting(false); + setSubmittingType(null); }); }; @@ -169,10 +178,11 @@ export const TedTalksSegment = () => { {downloadUrl.audio && (