mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-28 20:03:34 +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) {
|
||||||
|
|
|
||||||
|
|
@ -81,22 +81,8 @@ 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) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue