mirror of
https://github.com/AnimeThemes/animethemes-web.git
synced 2026-07-11 01:24:31 +02:00
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:
@@ -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={!isRevalidating} onClick={revalidate} {...props}>
|
||||
Page was last updated {lastBuildDescription} ago{apiRequestsDescription}. {rebuildDescription}
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
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" {...props}>
|
||||
Page was last updated {lastBuildDescription} ago.
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user