mirror of
https://github.com/sussy-code/smov.git
synced 2025-01-08 17:27:40 +01:00
b8e49850f4
Co-authored-by: James Hawkins <jhawki2005@gmail.com> Co-authored-by: Jip Frijlink <JipFr@users.noreply.github.com>
30 lines
941 B
TypeScript
30 lines
941 B
TypeScript
import { useMemo } from "react";
|
|
import { useVideoPlayerState } from "../VideoContext";
|
|
|
|
export function ShowTitleControl() {
|
|
const { videoState } = useVideoPlayerState();
|
|
|
|
const { current, seasons } = videoState.seasonData;
|
|
|
|
const currentSeasonInfo = useMemo(() => {
|
|
return seasons?.find((season) => season.id === current?.seasonId);
|
|
}, [seasons, current]);
|
|
|
|
const currentEpisodeInfo = useMemo(() => {
|
|
return currentSeasonInfo?.episodes?.find(
|
|
(episode) => episode.id === current?.episodeId
|
|
);
|
|
}, [currentSeasonInfo, current]);
|
|
|
|
if (!videoState.seasonData.isSeries) return null;
|
|
if (!videoState.seasonData.current) return null;
|
|
|
|
const selectedText = `S${currentSeasonInfo?.number} E${currentEpisodeInfo?.number}`;
|
|
|
|
return (
|
|
<p className="ml-8 select-none space-x-2 text-white">
|
|
<span>{selectedText}</span>
|
|
<span className="opacity-50">{currentEpisodeInfo?.title}</span>
|
|
</p>
|
|
);
|
|
}
|