+ {/* Off button */}
disable()}
selected={!selectedCaptionId}
>
{t("player.menus.subtitles.offChoice")}
- toggleLastUsed().catch(() => {})}
- selected={!!selectedCaptionId}
- >
- {t("player.menus.subtitles.onChoice")}
-
+
+ {/* Custom upload option */}
-
- router.navigate(
- backLink ? "/captions/source" : "/captions/sourceOverlay",
- )
- }
- rightText={
- useSubtitleStore((s) => s.isOpenSubtitles)
- ? ""
- : selectedLanguagePretty
- }
- >
- {t("player.menus.subtitles.SourceChoice")}
-
-
- router.navigate(
- backLink
- ? "/captions/opensubtitles"
- : "/captions/opensubtitlesOverlay",
- )
- }
- rightText={
- useSubtitleStore((s) => s.isOpenSubtitles)
- ? selectedLanguagePretty
- : ""
- }
- >
- {t("player.menus.subtitles.OpenSubtitlesChoice")}
-
+
+ {/* No subtitles available message */}
+ {!isLoadingExternalSubtitles &&
+ sourceCaptions.length === 0 &&
+ externalCaptions.length === 0 && (
+
+
+ {t("player.menus.subtitles.empty")}
+
+
+ )}
+
+ {/* Loading external subtitles */}
+ {isLoadingExternalSubtitles && externalCaptions.length === 0 && (
+
+
+ {t("player.menus.subtitles.loadingExternal")}
+
+
+ )}
+
+ {/* Source Subtitles Section */}
+ {sourceCaptions.length > 0 && (
+ <>
+
+ {t("player.menus.subtitles.SourceChoice")}
+
+ {sourceList.length > 0 ? (
+ sourceList.map(renderSubtitleOption)
+ ) : (
+
+ {t("player.menus.subtitles.notFound")}
+
+ )}
+ >
+ )}
+
+ {/* External Subtitles Section */}
+ {externalCaptions.length > 0 && (
+ <>
+
+ {t("player.menus.subtitles.OpenSubtitlesChoice")}
+
+ {externalList.length > 0 ? (
+ externalList.map(renderSubtitleOption)
+ ) : (
+
+ {t("player.menus.subtitles.notFound")}
+
+ )}
+ >
+ )}
+
+ {/* Loading indicator for external subtitles while source exists */}
+ {isLoadingExternalSubtitles && sourceCaptions.length > 0 && (
+
+ {t("player.menus.subtitles.loadingExternal") ||
+ "Loading external subtitles..."}
+
+ )}
>
diff --git a/src/components/player/atoms/settings/OpensubtitlesCaptionsView.tsx b/src/components/player/atoms/settings/OpensubtitlesCaptionsView.tsx
deleted file mode 100644
index 15150654..00000000
--- a/src/components/player/atoms/settings/OpensubtitlesCaptionsView.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-import { useMemo, useState } from "react";
-import { useTranslation } from "react-i18next";
-import { useAsyncFn } from "react-use";
-
-import { useCaptions } from "@/components/player/hooks/useCaptions";
-import { Menu } from "@/components/player/internals/ContextMenu";
-import { Input } from "@/components/player/internals/ContextMenu/Input";
-import { useOverlayRouter } from "@/hooks/useOverlayRouter";
-import { usePlayerStore } from "@/stores/player/store";
-
-import { CaptionOption } from "./CaptionsView";
-import { useSubtitleList } from "./SourceCaptionsView";
-
-export function OpenSubtitlesCaptionView({
- id,
- overlayBackLink,
-}: {
- id: string;
- overlayBackLink?: true;
-}) {
- const { t } = useTranslation();
- const router = useOverlayRouter(id);
- const selectedCaptionId = usePlayerStore((s) => s.caption.selected?.id);
- const [currentlyDownloading, setCurrentlyDownloading] = useState<
- string | null
- >(null);
- const { selectCaptionById } = useCaptions();
- const captionList = usePlayerStore((s) => s.captionList);
- const getHlsCaptionList = usePlayerStore((s) => s.display?.getCaptionList);
- const addExternalSubtitles = usePlayerStore((s) => s.addExternalSubtitles);
-
- const captions = useMemo(
- () =>
- captionList.length !== 0 ? captionList : (getHlsCaptionList?.() ?? []),
- [captionList, getHlsCaptionList],
- );
-
- const [searchQuery, setSearchQuery] = useState("");
- const subtitleList = useSubtitleList(
- captions.filter((x) => x.opensubtitles),
- searchQuery,
- );
-
- const [downloadReq, startDownload] = useAsyncFn(
- async (captionId: string) => {
- setCurrentlyDownloading(captionId);
- return selectCaptionById(captionId);
- },
- [selectCaptionById, setCurrentlyDownloading],
- );
-
- const [refreshReq, startRefresh] = useAsyncFn(async () => {
- return addExternalSubtitles();
- }, [addExternalSubtitles]);
-
- const content = subtitleList.length
- ? subtitleList.map((v) => {
- return (
-