mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Fix incorrect season showing when opening episode menu + fix selected season not resetting after reopen episode menu
This commit is contained in:
parent
f5492c7e21
commit
f30161fb1c
1 changed files with 17 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { ReactNode, useCallback, useEffect, useState } from "react";
|
import { ReactNode, useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAsync } from "react-use";
|
import { useAsync } from "react-use";
|
||||||
|
|
||||||
|
@ -196,9 +196,14 @@ function EpisodesOverlay({
|
||||||
}) {
|
}) {
|
||||||
const router = useOverlayRouter(id);
|
const router = useOverlayRouter(id);
|
||||||
const meta = usePlayerStore((s) => s.meta);
|
const meta = usePlayerStore((s) => s.meta);
|
||||||
const [selectedSeason, setSelectedSeason] = useState(
|
const [selectedSeason, setSelectedSeason] = useState("");
|
||||||
meta?.season?.tmdbId ?? ""
|
|
||||||
);
|
const lastActiveState = useRef(false);
|
||||||
|
useEffect(() => {
|
||||||
|
if (lastActiveState.current === router.isRouterActive) return;
|
||||||
|
lastActiveState.current = router.isRouterActive;
|
||||||
|
setSelectedSeason(meta?.season?.tmdbId ?? "");
|
||||||
|
}, [meta, selectedSeason, setSelectedSeason, router.isRouterActive]);
|
||||||
|
|
||||||
const setSeason = useCallback(
|
const setSeason = useCallback(
|
||||||
(seasonId: string) => {
|
(seasonId: string) => {
|
||||||
|
@ -215,12 +220,14 @@ function EpisodesOverlay({
|
||||||
<SeasonsView setSeason={setSeason} selectedSeason={selectedSeason} />
|
<SeasonsView setSeason={setSeason} selectedSeason={selectedSeason} />
|
||||||
</OverlayPage>
|
</OverlayPage>
|
||||||
<OverlayPage id={id} path="/episodes" width={343} height={431}>
|
<OverlayPage id={id} path="/episodes" width={343} height={431}>
|
||||||
<EpisodesView
|
{selectedSeason.length > 0 ? (
|
||||||
selectedSeason={selectedSeason}
|
<EpisodesView
|
||||||
id={id}
|
selectedSeason={selectedSeason}
|
||||||
goBack={() => router.navigate("/")}
|
id={id}
|
||||||
onChange={onChange}
|
goBack={() => router.navigate("/")}
|
||||||
/>
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
</OverlayPage>
|
</OverlayPage>
|
||||||
</OverlayRouter>
|
</OverlayRouter>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
Loading…
Reference in a new issue