mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-21 00:32:04 +00:00
Trakt scrobble big fix
This commit is contained in:
parent
b2a9708856
commit
dda34b6982
3 changed files with 39 additions and 25 deletions
|
|
@ -1160,15 +1160,29 @@ const AndroidVideoPlayer: React.FC = () => {
|
||||||
}
|
}
|
||||||
}, [id, type, paused, currentTime, duration]);
|
}, [id, type, paused, currentTime, duration]);
|
||||||
|
|
||||||
|
// Use refs to track latest values for unmount cleanup without causing effect re-runs
|
||||||
|
const currentTimeRef = useRef(currentTime);
|
||||||
|
const durationRef = useRef(duration);
|
||||||
|
|
||||||
|
// Keep refs updated with latest values
|
||||||
|
useEffect(() => {
|
||||||
|
currentTimeRef.current = currentTime;
|
||||||
|
}, [currentTime]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
durationRef.current = duration;
|
||||||
|
}, [duration]);
|
||||||
|
|
||||||
|
// Cleanup effect - only runs on actual component unmount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
if (id && type && duration > 0) {
|
if (id && type && durationRef.current > 0) {
|
||||||
saveWatchProgress();
|
saveWatchProgress();
|
||||||
// Final Trakt sync on component unmount
|
// Final Trakt sync on component unmount
|
||||||
traktAutosync.handlePlaybackEnd(currentTime, duration, 'unmount');
|
traktAutosync.handlePlaybackEnd(currentTimeRef.current, durationRef.current, 'unmount');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [id, type, currentTime, duration]);
|
}, [id, type]); // Only id and type - NOT currentTime or duration
|
||||||
|
|
||||||
const seekToTime = (rawSeconds: number) => {
|
const seekToTime = (rawSeconds: number) => {
|
||||||
// Clamp to just before the end of the media.
|
// Clamp to just before the end of the media.
|
||||||
|
|
|
||||||
|
|
@ -838,15 +838,29 @@ const KSPlayerCore: React.FC = () => {
|
||||||
}
|
}
|
||||||
}, [id, type, paused, duration]);
|
}, [id, type, paused, duration]);
|
||||||
|
|
||||||
|
// Use refs to track latest values for unmount cleanup without causing effect re-runs
|
||||||
|
const currentTimeRef = useRef(currentTime);
|
||||||
|
const durationRef = useRef(duration);
|
||||||
|
|
||||||
|
// Keep refs updated with latest values
|
||||||
|
useEffect(() => {
|
||||||
|
currentTimeRef.current = currentTime;
|
||||||
|
}, [currentTime]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
durationRef.current = duration;
|
||||||
|
}, [duration]);
|
||||||
|
|
||||||
|
// Cleanup effect - only runs on actual component unmount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
if (id && type && duration > 0) {
|
if (id && type && durationRef.current > 0) {
|
||||||
saveWatchProgress();
|
saveWatchProgress();
|
||||||
// Final Trakt sync on component unmount
|
// Final Trakt sync on component unmount
|
||||||
traktAutosync.handlePlaybackEnd(currentTime, duration, 'unmount');
|
traktAutosync.handlePlaybackEnd(currentTimeRef.current, durationRef.current, 'unmount');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [id, type, currentTime, duration]);
|
}, [id, type]); // Only id and type - NOT currentTime or duration
|
||||||
|
|
||||||
const onPlaying = () => {
|
const onPlaying = () => {
|
||||||
if (isMounted.current && !isSeeking.current) {
|
if (isMounted.current && !isSeeking.current) {
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ const UpNextButton: React.FC<UpNextButtonProps> = ({
|
||||||
const { tmdbService } = require('../../../services/tmdbService');
|
const { tmdbService } = require('../../../services/tmdbService');
|
||||||
const url = tmdbService.getImageUrl(anyEpisode.still_path, 'w500');
|
const url = tmdbService.getImageUrl(anyEpisode.still_path, 'w500');
|
||||||
if (url) imageUri = url;
|
if (url) imageUri = url;
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -81,33 +81,19 @@ const UpNextButton: React.FC<UpNextButtonProps> = ({
|
||||||
return timeRemaining < 61 && timeRemaining > 10;
|
return timeRemaining < 61 && timeRemaining > 10;
|
||||||
}, [nextEpisode, duration, currentTime]);
|
}, [nextEpisode, duration, currentTime]);
|
||||||
|
|
||||||
// Debug log inputs and computed state on changes
|
// Debug logging removed to reduce console noise
|
||||||
useEffect(() => {
|
// The state is computed in shouldShow useMemo above
|
||||||
try {
|
|
||||||
const timeRemaining = duration - currentTime;
|
|
||||||
logger.log('[UpNextButton] state', {
|
|
||||||
hasNextEpisode: !!nextEpisode,
|
|
||||||
currentTime,
|
|
||||||
duration,
|
|
||||||
timeRemaining,
|
|
||||||
isLoading,
|
|
||||||
shouldShow,
|
|
||||||
controlsVisible,
|
|
||||||
controlsFixedOffset,
|
|
||||||
});
|
|
||||||
} catch {}
|
|
||||||
}, [nextEpisode, currentTime, duration, isLoading, shouldShow, controlsVisible, controlsFixedOffset]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldShow && !visible) {
|
if (shouldShow && !visible) {
|
||||||
try { logger.log('[UpNextButton] showing with animation'); } catch {}
|
try { logger.log('[UpNextButton] showing with animation'); } catch { }
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
Animated.parallel([
|
Animated.parallel([
|
||||||
Animated.timing(opacity, { toValue: 1, duration: 400, useNativeDriver: true }),
|
Animated.timing(opacity, { toValue: 1, duration: 400, useNativeDriver: true }),
|
||||||
Animated.spring(scale, { toValue: 1, tension: 100, friction: 8, useNativeDriver: true }),
|
Animated.spring(scale, { toValue: 1, tension: 100, friction: 8, useNativeDriver: true }),
|
||||||
]).start();
|
]).start();
|
||||||
} else if (!shouldShow && visible) {
|
} else if (!shouldShow && visible) {
|
||||||
try { logger.log('[UpNextButton] hiding with animation'); } catch {}
|
try { logger.log('[UpNextButton] hiding with animation'); } catch { }
|
||||||
Animated.parallel([
|
Animated.parallel([
|
||||||
Animated.timing(opacity, { toValue: 0, duration: 200, useNativeDriver: true }),
|
Animated.timing(opacity, { toValue: 0, duration: 200, useNativeDriver: true }),
|
||||||
Animated.timing(scale, { toValue: 0.8, duration: 200, useNativeDriver: true }),
|
Animated.timing(scale, { toValue: 0.8, duration: 200, useNativeDriver: true }),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue