|
|
|
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
|
|
|
|
import { useMemo } from "react"; |
|
|
|
|
import { useCallback, useMemo } from "react"; |
|
|
|
|
import { Trans, useTranslation } from "react-i18next"; |
|
|
|
|
|
|
|
|
|
import { Button } from "@/components/buttons/Button"; |
|
|
|
@ -46,13 +46,13 @@ export function DownloadView({ id }: { id: string }) {
@@ -46,13 +46,13 @@ export function DownloadView({ id }: { id: string }) {
|
|
|
|
|
|
|
|
|
|
const sourceType = usePlayerStore((s) => s.source?.type); |
|
|
|
|
const selectedCaption = usePlayerStore((s) => s.caption?.selected); |
|
|
|
|
const subtitleUrl = useMemo( |
|
|
|
|
() => |
|
|
|
|
selectedCaption |
|
|
|
|
? convertSubtitlesToSrtDataurl(selectedCaption?.srtData) |
|
|
|
|
: null, |
|
|
|
|
[selectedCaption], |
|
|
|
|
); |
|
|
|
|
const openSubtitleDownload = useCallback(() => { |
|
|
|
|
const dataUrl = selectedCaption |
|
|
|
|
? convertSubtitlesToSrtDataurl(selectedCaption?.srtData) |
|
|
|
|
: null; |
|
|
|
|
if (!dataUrl) return; |
|
|
|
|
window.open(dataUrl); |
|
|
|
|
}, [selectedCaption]); |
|
|
|
|
|
|
|
|
|
if (!downloadUrl) return null; |
|
|
|
|
|
|
|
|
@ -74,10 +74,9 @@ export function DownloadView({ id }: { id: string }) {
@@ -74,10 +74,9 @@ export function DownloadView({ id }: { id: string }) {
|
|
|
|
|
</Button> |
|
|
|
|
<Button |
|
|
|
|
className="w-full mt-2" |
|
|
|
|
href={subtitleUrl ?? undefined} |
|
|
|
|
disabled={!subtitleUrl} |
|
|
|
|
onClick={openSubtitleDownload} |
|
|
|
|
disabled={!selectedCaption} |
|
|
|
|
theme="secondary" |
|
|
|
|
download="subtitles.srt" |
|
|
|
|
> |
|
|
|
|
{t("player.menus.downloads.downloadSubtitle")} |
|
|
|
|
</Button> |
|
|
|
@ -109,8 +108,8 @@ export function DownloadView({ id }: { id: string }) {
@@ -109,8 +108,8 @@ export function DownloadView({ id }: { id: string }) {
|
|
|
|
|
</Button> |
|
|
|
|
<Button |
|
|
|
|
className="w-full mt-2" |
|
|
|
|
href={subtitleUrl ?? undefined} |
|
|
|
|
disabled={!subtitleUrl} |
|
|
|
|
onClick={openSubtitleDownload} |
|
|
|
|
disabled={!selectedCaption} |
|
|
|
|
theme="secondary" |
|
|
|
|
download="subtitles.srt" |
|
|
|
|
> |
|
|
|
|