mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-05-18 07:51:46 +00:00
dedup fix streamscreen
This commit is contained in:
parent
c358c794ec
commit
7a64851256
1 changed files with 85 additions and 67 deletions
|
|
@ -498,10 +498,11 @@ export const StreamsScreen = () => {
|
||||||
const { colors } = currentTheme;
|
const { colors } = currentTheme;
|
||||||
const { pauseTrailer, resumeTrailer } = useTrailer();
|
const { pauseTrailer, resumeTrailer } = useTrailer();
|
||||||
|
|
||||||
// Add ref to prevent excessive updates
|
// Add refs to prevent excessive updates and duplicate loads
|
||||||
const isMounted = useRef(true);
|
const isMounted = useRef(true);
|
||||||
const loadStartTimeRef = useRef(0);
|
const loadStartTimeRef = useRef(0);
|
||||||
const hasDoneInitialLoadRef = useRef(false);
|
const hasDoneInitialLoadRef = useRef(false);
|
||||||
|
const isLoadingStreamsRef = useRef(false);
|
||||||
|
|
||||||
// CustomAlert state
|
// CustomAlert state
|
||||||
const [alertVisible, setAlertVisible] = useState(false);
|
const [alertVisible, setAlertVisible] = useState(false);
|
||||||
|
|
@ -729,9 +730,23 @@ export const StreamsScreen = () => {
|
||||||
|
|
||||||
// Update useEffect to check for sources
|
// Update useEffect to check for sources
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
// Reset initial load state when content changes
|
||||||
|
hasDoneInitialLoadRef.current = false;
|
||||||
|
isLoadingStreamsRef.current = false;
|
||||||
|
|
||||||
const checkProviders = async () => {
|
const checkProviders = async () => {
|
||||||
if (__DEV__) console.log('[StreamsScreen] checkProviders() start', { id, type, episodeId, fromPlayer });
|
if (__DEV__) console.log('[StreamsScreen] checkProviders() start', { id, type, episodeId, fromPlayer });
|
||||||
logger.log(`[StreamsScreen] checkProviders() start id=${id} type=${type} episodeId=${episodeId || 'none'} fromPlayer=${!!fromPlayer}`);
|
logger.log(`[StreamsScreen] checkProviders() start id=${id} type=${type} episodeId=${episodeId || 'none'} fromPlayer=${!!fromPlayer}`);
|
||||||
|
|
||||||
|
// Prevent duplicate calls if already loading
|
||||||
|
if (isLoadingStreamsRef.current) {
|
||||||
|
if (__DEV__) console.log('[StreamsScreen] checkProviders() skipping - already loading');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isLoadingStreamsRef.current = true;
|
||||||
|
|
||||||
|
try {
|
||||||
// Check for Stremio addons
|
// Check for Stremio addons
|
||||||
const hasStremioProviders = await stremioService.hasStreamProviders();
|
const hasStremioProviders = await stremioService.hasStreamProviders();
|
||||||
if (__DEV__) console.log('[StreamsScreen] hasStremioProviders:', hasStremioProviders);
|
if (__DEV__) console.log('[StreamsScreen] hasStremioProviders:', hasStremioProviders);
|
||||||
|
|
@ -803,6 +818,9 @@ export const StreamsScreen = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
isLoadingStreamsRef.current = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
checkProviders();
|
checkProviders();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue