pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix translated caption not applying when menu is closed

vlOd2 5539061a 44618524

+21 -18
+18
src/components/player/atoms/Captions.tsx
··· 2 2 3 3 import { Icons } from "@/components/Icon"; 4 4 import { OverlayAnchor } from "@/components/overlays/OverlayAnchor"; 5 + import { useCaptions } from "@/components/player/hooks/useCaptions"; 5 6 import { VideoPlayerButton } from "@/components/player/internals/Button"; 6 7 import { useOverlayRouter } from "@/hooks/useOverlayRouter"; 7 8 import { usePlayerStore } from "@/stores/player/store"; ··· 9 10 export function Captions() { 10 11 const router = useOverlayRouter("settings"); 11 12 const setHasOpenOverlay = usePlayerStore((s) => s.setHasOpenOverlay); 13 + const { setDirectCaption } = useCaptions(); 14 + const translateTask = usePlayerStore((s) => s.caption.translateTask); 12 15 13 16 useEffect(() => { 14 17 setHasOpenOverlay(router.isRouterActive); 15 18 }, [setHasOpenOverlay, router.isRouterActive]); 19 + 20 + useEffect(() => { 21 + if (!translateTask) { 22 + return; 23 + } 24 + if (translateTask.done) { 25 + const tCaption = translateTask.translatedCaption!; 26 + setDirectCaption(tCaption, { 27 + id: tCaption.id, 28 + url: "", 29 + language: tCaption.language, 30 + needsProxy: false, 31 + }); 32 + } 33 + }, [translateTask, setDirectCaption]); 16 34 17 35 return ( 18 36 <OverlayAnchor id={router.id}>
+3 -18
src/components/player/atoms/settings/TranslateSubtitleView.tsx
··· 71 71 "cy", 72 72 ]; 73 73 74 - export interface LanguageSubtitlesViewProps { 74 + export interface TranslateSubtitlesViewProps { 75 75 id: string; 76 76 caption: CaptionListItem; 77 77 overlayBackLink?: boolean; ··· 81 81 id, 82 82 caption, 83 83 overlayBackLink, 84 - }: LanguageSubtitlesViewProps) { 84 + }: TranslateSubtitlesViewProps) { 85 85 const { t } = useTranslation(); 86 86 const router = useOverlayRouter(id); 87 - const { setDirectCaption, disable: disableCaptions } = useCaptions(); 87 + const { disable: disableCaptions } = useCaptions(); 88 88 const translateTask = usePlayerStore((s) => s.caption.translateTask); 89 89 const translateCaption = usePlayerStore((s) => s.translateCaption); 90 90 const clearTranslateTask = usePlayerStore((s) => s.clearTranslateTask); 91 - 92 - useEffect(() => { 93 - if (!translateTask) { 94 - return; 95 - } 96 - if (translateTask.done) { 97 - const tCaption = translateTask.translatedCaption!; 98 - setDirectCaption(tCaption, { 99 - id: tCaption.id, 100 - url: "", 101 - language: tCaption.language, 102 - needsProxy: false, 103 - }); 104 - } 105 - }, [translateTask, setDirectCaption]); 106 91 107 92 function renderTargetLang(langCode: string) { 108 93 const friendlyName = getPrettyLanguageNameFromLocale(langCode);