From 82bd88f33d631b19e079e9e826697b6eb118fe0d Mon Sep 17 00:00:00 2001 From: tapframe Date: Tue, 8 Jul 2025 13:37:01 +0530 Subject: [PATCH] Add subtitle fetching and UI enhancements in SubtitleModals --- .../player/modals/SubtitleModals.tsx | 319 +++++++++++++++--- 1 file changed, 281 insertions(+), 38 deletions(-) diff --git a/src/components/player/modals/SubtitleModals.tsx b/src/components/player/modals/SubtitleModals.tsx index e7f3bef..14e8bad 100644 --- a/src/components/player/modals/SubtitleModals.tsx +++ b/src/components/player/modals/SubtitleModals.tsx @@ -128,6 +128,12 @@ export const SubtitleModals: React.FC = ({ }; }, [showSubtitleLanguageModal]); + React.useEffect(() => { + if (showSubtitleLanguageModal && !isLoadingSubtitleList && availableSubtitles.length === 0) { + fetchAvailableSubtitles(); + } + }, [showSubtitleLanguageModal]); + const modalStyle = useAnimatedStyle(() => ({ opacity: modalOpacity.value, })); @@ -372,6 +378,48 @@ export const SubtitleModals: React.FC = ({ Subtitle Source + fetchAvailableSubtitles()} + > + + + + Search Online Subtitles + + + + + + + + + = ({ - {availableSubtitles.map((sub) => ( - - { - loadWyzieSubtitle(sub); - handleLanguageClose(); - }} - activeOpacity={0.85} - > - - - { + const isCustomSelected = useCustomSubtitles && customSubtitles.length > 0; + const isThisSubSelected = isCustomSelected; // Since we only load one custom sub at a time + + return ( + + { + loadWyzieSubtitle(sub); + handleLanguageClose(); + }} + activeOpacity={0.85} + disabled={isLoadingSubtitles} + > + + + + + {sub.display} + + + {isThisSubSelected && ( + + + + LOADED + + + )} + + + + {isThisSubSelected && ( + + )} + + + + - {sub.display} - - - + {isLoadingSubtitles ? ( + + ) : ( + + )} - - - - - ))} + + + ); + })} )} + + {/* No Subtitles Option */} + + { + selectTextTrack(-1); + handleLanguageClose(); + }} + activeOpacity={0.85} + > + + + + + No Subtitles + + + {selectedTextTrack === -1 && !useCustomSubtitles && ( + + + + ACTIVE + + + )} + + + + + + + + + + + + +