From ca2bab30a4beb221d3e253e59eae0585ca5f6d7c Mon Sep 17 00:00:00 2001 From: mrjvs Date: Sun, 22 Oct 2023 20:17:28 +0200 Subject: [PATCH] make download button use real link, and improve PC download text Co-authored-by: Jip Frijlink --- .../player/atoms/settings/Downloads.tsx | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/components/player/atoms/settings/Downloads.tsx b/src/components/player/atoms/settings/Downloads.tsx index 823ae0b9..b0b51bbf 100644 --- a/src/components/player/atoms/settings/Downloads.tsx +++ b/src/components/player/atoms/settings/Downloads.tsx @@ -1,13 +1,27 @@ +import { useMemo } from "react"; + import { Icon, Icons } from "@/components/Icon"; import { OverlayPage } from "@/components/overlays/OverlayPage"; import { Menu } from "@/components/player/internals/ContextMenu"; import { useOverlayRouter } from "@/hooks/useOverlayRouter"; import { usePlayerStore } from "@/stores/player/store"; +function useDownloadLink() { + const source = usePlayerStore((s) => s.source); + const currentQuality = usePlayerStore((s) => s.currentQuality); + const url = useMemo(() => { + if (source?.type === "file" && currentQuality) + return source.qualities[currentQuality]?.url ?? null; + return null; + }, [source, currentQuality]); + return url; +} + export function DownloadView({ id }: { id: string }) { const router = useOverlayRouter(id); - const source = usePlayerStore((s) => s.source); - if (source?.type === "hls") return null; + const downloadUrl = useDownloadLink(); + + if (!downloadUrl) return null; return ( <> @@ -36,7 +50,7 @@ export function DownloadView({ id }: { id: string }) { - On PC, click the{" "} - - three dots - - {" "} - and click download. + On PC, right click the video and select{" "} + Save video as