mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Remove shitty auto next episode
This commit is contained in:
parent
a69c4d2b8c
commit
4155c4b610
1 changed files with 15 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
|||
import classNames from "classnames";
|
||||
import React, { useCallback, useEffect, useState } from "react";
|
||||
import React, { useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Icon, Icons } from "@/components/Icon";
|
||||
|
@ -54,30 +54,12 @@ export function NextEpisodeButton(props: {
|
|||
const setShouldStartFromBeginning = usePlayerStore(
|
||||
(s) => s.setShouldStartFromBeginning,
|
||||
);
|
||||
const [countdown, setCountdown] = useState(15);
|
||||
|
||||
let show = false;
|
||||
if (showingState === "always") show = true;
|
||||
else if (showingState === "hover" && props.controlsShowing) show = true;
|
||||
if (isHidden || status !== "playing" || duration === 0) show = false;
|
||||
|
||||
useEffect(() => {
|
||||
// Initialize intervalId with 0, which is a safe value to clear if not reassigned.
|
||||
let intervalId: number = 0;
|
||||
if (show && countdown > 0) {
|
||||
intervalId = window.setInterval(() => {
|
||||
setCountdown((currentCountdown) => currentCountdown - 1);
|
||||
}, 1000);
|
||||
} else {
|
||||
window.clearInterval(intervalId); // No need for casting here.
|
||||
if (!show) {
|
||||
setCountdown(15); // Reset countdown when not showing.
|
||||
}
|
||||
}
|
||||
// Cleanup function to clear the interval when the component unmounts or the dependencies change.
|
||||
return () => window.clearInterval(intervalId);
|
||||
}, [show, countdown]);
|
||||
|
||||
const animation = showingState === "hover" ? "slide-up" : "fade";
|
||||
let bottom = "bottom-[calc(6rem+env(safe-area-inset-bottom))]";
|
||||
if (showingState === "always")
|
||||
|
@ -117,16 +99,10 @@ export function NextEpisodeButton(props: {
|
|||
>
|
||||
<div
|
||||
className={classNames([
|
||||
"absolute bottom-0 right-0 transition-[bottom] duration-200 flex flex-col items-center space-y-3",
|
||||
"absolute bottom-0 right-0 transition-[bottom] duration-200 flex items-center space-x-3",
|
||||
bottom,
|
||||
])}
|
||||
>
|
||||
{countdown > 0 && show && (
|
||||
<div className="text-white mb-2">
|
||||
{t("player.nextEpisode.nextIn", { seconds: countdown })}
|
||||
</div>
|
||||
)}
|
||||
<div className="flex items-center space-x-3">
|
||||
<Button
|
||||
className="py-px box-content bg-buttons-secondary hover:bg-buttons-secondaryHover bg-opacity-90 text-buttons-secondaryText justify-center items-center"
|
||||
onClick={() => startCurrentEpisodeFromBeginning()}
|
||||
|
@ -141,7 +117,6 @@ export function NextEpisodeButton(props: {
|
|||
{t("player.nextEpisode.next")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Transition>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue