chore: player - clean up and use handleNextVideoNavigation

Signed-off-by: Lachezar Lechev <lachezar@ambire.com>
This commit is contained in:
Lachezar Lechev 2025-10-24 10:23:58 +03:00
parent 32cf4cc12e
commit 3d163cf440
No known key found for this signature in database
GPG key ID: 69BDCB3ED8CE8037

View file

@ -105,22 +105,27 @@ const Player = ({ urlParams, queryParams }) => {
video.setProp('extraSubtitlesOutlineColor', settings.subtitlesOutlineColor);
}, [settings.subtitlesSize, settings.subtitlesOffset, settings.subtitlesTextColor, settings.subtitlesBackgroundColor, settings.subtitlesOutlineColor]);
// const handleNextVideoNavigation = React.useCallback((deepLinks, bingeWatching, ended) => {
// if (bingeWatching && !ended) {
// if (deepLinks.player) {
// isNavigating.current = true;
// window.location.replace(deepLinks.player);
// } else if (deepLinks.metaDetailsStreams) {
// isNavigating.current = true;
// window.location.replace(deepLinks.metaDetailsStreams);
// }
// } else {
// if (!ended && deepLinks.metaDetailsStreams) {
// isNavigating.current = true;
// window.location.replace(deepLinks.metaDetailsStreams);
// }
// }
// }, []);
const handleNextVideoNavigation = React.useCallback((deepLinks, bingeWatching, ended) => {
if (ended) {
if (profile.settings.bingeWatching) {
if (deepLinks.player) {
isNavigating.current = true;
window.location.replace(deepLinks.player);
} else if (deepLinks.metaDetailsStreams) {
isNavigating.current = true;
window.location.replace(deepLinks.metaDetailsStreams);
}
}
} else {
if (deepLinks.player) {
isNavigating.current = true;
window.location.replace(deepLinks.player);
} else if (deepLinks.metaDetailsStreams) {
isNavigating.current = true;
window.location.replace(deepLinks.metaDetailsStreams);
}
}
}, []);
const onEnded = React.useCallback(() => {
// here we need to explicitly check for isNavigating.current
@ -134,16 +139,7 @@ const Player = ({ urlParams, queryParams }) => {
nextVideo();
const deepLinks = window.playerNextVideo.deepLinks;
// handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, true);
if (profile.settings.bingeWatching) {
if (deepLinks.player) {
isNavigating.current = true;
window.location.replace(deepLinks.player);
} else if (deepLinks.metaDetailsStreams) {
isNavigating.current = true;
window.location.replace(deepLinks.metaDetailsStreams);
}
}
handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, true);
} else {
window.history.back();
@ -274,17 +270,9 @@ const Player = ({ urlParams, queryParams }) => {
nextVideo();
const deepLinks = player.nextVideo.deepLinks;
if (deepLinks.player) {
isNavigating.current = true;
window.location.replace(deepLinks.player);
} else if (deepLinks.metaDetailsStreams) {
isNavigating.current = true;
window.location.replace(deepLinks.metaDetailsStreams);
}
// handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, false);
handleNextVideoNavigation(deepLinks, profile.settings.bingeWatching, false);
}
// }, [player.nextVideo, handleNextVideoNavigation]);
}, [player.nextVideo, profile.settings]);
}, [player.nextVideo, handleNextVideoNavigation, profile.settings]);
const onVideoClick = React.useCallback(() => {
if (video.state.paused !== null) {