mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +01:00
Make download subtitle not automatically crash the tab but only after clicking (if ram is too low)
This commit is contained in:
parent
392c60a9f9
commit
a87f4cf222
1 changed files with 12 additions and 13 deletions
|
@ -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 }) {
|
|||
|
||||
const sourceType = usePlayerStore((s) => s.source?.type);
|
||||
const selectedCaption = usePlayerStore((s) => s.caption?.selected);
|
||||
const subtitleUrl = useMemo(
|
||||
() =>
|
||||
selectedCaption
|
||||
const openSubtitleDownload = useCallback(() => {
|
||||
const dataUrl = selectedCaption
|
||||
? convertSubtitlesToSrtDataurl(selectedCaption?.srtData)
|
||||
: null,
|
||||
[selectedCaption],
|
||||
);
|
||||
: null;
|
||||
if (!dataUrl) return;
|
||||
window.open(dataUrl);
|
||||
}, [selectedCaption]);
|
||||
|
||||
if (!downloadUrl) return null;
|
||||
|
||||
|
@ -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 }) {
|
|||
</Button>
|
||||
<Button
|
||||
className="w-full mt-2"
|
||||
href={subtitleUrl ?? undefined}
|
||||
disabled={!subtitleUrl}
|
||||
onClick={openSubtitleDownload}
|
||||
disabled={!selectedCaption}
|
||||
theme="secondary"
|
||||
download="subtitles.srt"
|
||||
>
|
||||
|
|
Loading…
Reference in a new issue