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.

Revert "wait untill subtitles are loaded before picking one for reenabling"

This reverts commit 8d8d4659dbd893ca6355115e0a9279b5e0f4cdb5.

Pas 88faf5bb c7e57493

+7 -51
-7
src/components/player/hooks/useCaptions.ts
··· 24 24 const setIsOpenSubtitles = useSubtitleStore((s) => s.setIsOpenSubtitles); 25 25 26 26 const captionList = usePlayerStore((s) => s.captionList); 27 - const isLoadingExternalSubtitles = usePlayerStore( 28 - (s) => s.isLoadingExternalSubtitles, 29 - ); 30 27 const getHlsCaptionList = usePlayerStore((s) => s.display?.getCaptionList); 31 28 const source = usePlayerStore((s) => s.source); 32 29 const selectedCaption = usePlayerStore((s) => s.caption.selected); ··· 188 185 useEffect(() => { 189 186 if (!selectedCaption) return; 190 187 191 - // Don't clear while external subtitles are still loading - the caption might appear 192 - if (isLoadingExternalSubtitles) return; 193 - 194 188 // Skip validation for custom/pasted captions that aren't in the caption list 195 189 const isCustomCaption = 196 190 selectedCaption.id === "custom-caption" || ··· 232 226 setCaption, 233 227 selectCaptionById, 234 228 currentTranslateTask, 235 - isLoadingExternalSubtitles, 236 229 ]); 237 230 238 231 return {
+7 -44
src/components/player/hooks/useInitializePlayer.ts
··· 1 - import { useCallback, useEffect, useMemo, useRef, useState } from "react"; 1 + import { useCallback, useEffect, useMemo, useRef } from "react"; 2 2 3 3 import { usePlayerStore } from "@/stores/player/store"; 4 - import { useSubtitleStore } from "@/stores/subtitles"; 5 4 import { useVolumeStore } from "@/stores/volume"; 6 5 7 6 import { useCaptions } from "./useCaptions"; ··· 25 24 () => (source ? JSON.stringify(source) : null), 26 25 [source], 27 26 ); 28 - const captionList = usePlayerStore((s) => s.captionList); 29 - const isLoadingExternalSubtitles = usePlayerStore( 30 - (s) => s.isLoadingExternalSubtitles, 31 - ); 32 - const getHlsCaptionList = usePlayerStore((s) => s.display?.getCaptionList); 33 - const enabled = useSubtitleStore((s) => s.enabled); 34 27 const { selectLastUsedLanguageIfEnabled } = useCaptions(); 35 28 36 - // Trigger re-run when HLS tracks may have loaded (they load after manifest) 37 - const [hlsRetryTrigger, setHlsRetryTrigger] = useState(0); 38 - const hasRetriedForSourceRef = useRef<string | null>(null); 29 + // Only select subtitles on initial load, not when source changes 30 + const hasInitializedRef = useRef(false); 39 31 40 32 useEffect(() => { 41 - if (!sourceIdentifier || !enabled) return; 42 - 43 - // Wait for external subtitles to finish loading before selecting 44 - // This ensures we have the full caption list (provider + external) before picking 45 - if (isLoadingExternalSubtitles) return; 46 - 47 - const captions = 48 - captionList.length > 0 ? captionList : (getHlsCaptionList?.() ?? []); 49 - if (captions.length === 0) { 50 - // For HLS sources, tracks may load after manifest - retry once per source 51 - const alreadyRetried = 52 - hasRetriedForSourceRef.current === sourceIdentifier; 53 - if (source?.type === "hls" && !alreadyRetried) { 54 - hasRetriedForSourceRef.current = sourceIdentifier; 55 - const retryTimer = setTimeout( 56 - () => setHlsRetryTrigger((n) => n + 1), 57 - 2000, 58 - ); 59 - return () => clearTimeout(retryTimer); 60 - } 61 - return; 33 + if (sourceIdentifier && !hasInitializedRef.current) { 34 + hasInitializedRef.current = true; 35 + selectLastUsedLanguageIfEnabled(); 62 36 } 63 - 64 - selectLastUsedLanguageIfEnabled(); 65 - }, [ 66 - sourceIdentifier, 67 - source?.type, 68 - enabled, 69 - isLoadingExternalSubtitles, 70 - captionList, 71 - getHlsCaptionList, 72 - selectLastUsedLanguageIfEnabled, 73 - hlsRetryTrigger, 74 - ]); 37 + }, [sourceIdentifier, selectLastUsedLanguageIfEnabled]); 75 38 }