fix: Fixed play next not working with disabled autoplay (#205)

* Added back last update date on pages for everyone to see.
This commit is contained in:
Mani
2024-04-19 20:56:29 +02:00
committed by GitHub
parent 295d93b980
commit d13a22eaa8
2 changed files with 23 additions and 17 deletions
+10 -7
View File
@@ -24,10 +24,6 @@ export function PageRevalidation({ lastBuildAt, apiRequests, ...props }: PageRev
const [isRevalidating, setRevalidating] = useState(false);
if (!canRevalidate) {
return null;
}
function revalidate() {
if (isRevalidating || !canRevalidate) {
return;
@@ -64,14 +60,21 @@ export function PageRevalidation({ lastBuildAt, apiRequests, ...props }: PageRev
? ` using ${apiRequests} API request${apiRequests === 1 ? "" : "s"}`
: "";
const canRebuild = !isRevalidating;
const rebuildDescription = isRevalidating
? "Rebuild in progress... The page will automatically reload after it's finished."
: "Click to start a rebuild.";
if (canRevalidate) {
return (
<Text variant="small" color="text-disabled" link={canRebuild} onClick={revalidate} {...props}>
Page was last built {lastBuildDescription} ago{apiRequestsDescription}. {rebuildDescription}
<Text variant="small" color="text-disabled" link={!isRevalidating} onClick={revalidate} {...props}>
Page was last updated {lastBuildDescription} ago{apiRequestsDescription}. {rebuildDescription}
</Text>
);
}
return (
<Text variant="small" color="text-disabled" {...props}>
Page was last updated {lastBuildDescription} ago.
</Text>
);
}
+13 -10
View File
@@ -110,19 +110,22 @@ export function VideoPlayer({ video, background, children, overlay, ...props }:
: null;
const playNextTrack = useCallback((navigate = false) => {
if (
(
isWatchListUsingLocalAutoPlay && isLocalAutoPlay ||
!isWatchListUsingLocalAutoPlay && isGlobalAutoPlay
) &&
nextVideoPath
) {
if (nextVideoPath) {
setCurrentWatchListItem(nextVideo);
if (navigate) {
router.push(nextVideoPath);
}
}
}, [isGlobalAutoPlay, isLocalAutoPlay, isWatchListUsingLocalAutoPlay, nextVideo, nextVideoPath, router, setCurrentWatchListItem]);
}, [nextVideo, nextVideoPath, router, setCurrentWatchListItem]);
const autoPlayNextTrack = useCallback(() => {
if (
isWatchListUsingLocalAutoPlay && isLocalAutoPlay ||
!isWatchListUsingLocalAutoPlay && isGlobalAutoPlay
) {
playNextTrack(!background);
}
}, [background, isGlobalAutoPlay, isLocalAutoPlay, isWatchListUsingLocalAutoPlay, playNextTrack]);
useEffect(() => {
if (playerRef.current) {
@@ -286,7 +289,7 @@ export function VideoPlayer({ video, background, children, overlay, ...props }:
onPause={() => setPlaying(false)}
onEnded={() => {
setPlaying(false);
playNextTrack(!background);
autoPlayNextTrack();
}}
onTimeUpdate={updateProgress}
onVolumeChange={(event: SyntheticEvent<HTMLAudioElement>) => setGlobalVolume(event.currentTarget.volume)}
@@ -303,7 +306,7 @@ export function VideoPlayer({ video, background, children, overlay, ...props }:
onPause={() => setPlaying(false)}
onEnded={() => {
setPlaying(false);
playNextTrack(!background);
autoPlayNextTrack();
}}
onPointerDown={onPlayerClick}
onTimeUpdate={updateProgress}