Skip to content

Commit

Permalink
fix the bug of video title
Browse files Browse the repository at this point in the history
  • Loading branch information
GokuxSS4 committed Feb 26, 2025
1 parent 0400f4c commit 5c37ceb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 0 additions & 3 deletions components/watch/ListOfEpisodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ export function ListOfEpisodes({
animeEpisodes,
currentEpisode,
handleCurrentEpisode,
handleTitle,
handleVideoSkeletonVisibilty,
}: {
animeEpisodes: HiAnime.ScrapedAnimeEpisodes;
currentEpisode: string;
handleCurrentEpisode: (episode: string) => void;
handleTitle: (title: string) => void;
handleVideoSkeletonVisibilty: (isVisible: boolean) => void;
}) {
const totlaEpisodes = animeEpisodes.totalEpisodes;
Expand Down Expand Up @@ -80,7 +78,6 @@ export function ListOfEpisodes({
}`}
onClick={() => {
handleCurrentEpisode(episode.episodeId as string);
handleTitle(episode.title as string);
handleVideoSkeletonVisibilty(true);
}}
>
Expand Down
8 changes: 5 additions & 3 deletions components/watch/VideoContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ type ServerInfoType = {

export function VideoContainer({
currentEpisode,
title,
isVideoSkeletonVisible,
handleVideoSkeletonVisibilty,
animeEpisodes,
handleCurrentEpisode,
}: {
currentEpisode: string;
title: string;
isVideoSkeletonVisible: boolean;
handleVideoSkeletonVisibilty: (isVisible: boolean) => void;
animeEpisodes: HiAnime.ScrapedAnimeEpisodes;
Expand All @@ -51,6 +49,10 @@ export function VideoContainer({
const { settings, setSettings } = useSettings();
const { autoPlay, autoNext, autoSkip } = settings;

const title = animeEpisodes.episodes.find(
(episode) => episode.episodeId === currentEpisode,
)?.title;

const toggleAutoPlay = () =>
setSettings({ ...settings, autoPlay: !autoPlay });
const toggleAutoNext = () =>
Expand Down Expand Up @@ -313,7 +315,7 @@ export function VideoContainer({
) : serverResources && !isVideoSkeletonVisible ? (
<div className="w-full h-full">
<VidstackDefaultPlayer
title={title}
title={title || ""}
videoUrl={serverResources.sources[0].url}
subtitleUrls={serverResources.tracks.filter(
(track: any) => track.kind === "captions",
Expand Down
3 changes: 0 additions & 3 deletions components/watch/WatchContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ export function WatchContainer({
const [currentEpisode, setCurrentEpisode] = useState(
getInRecentWatches(animeId) || animeEpisodes.episodes[0].episodeId,
);
const [title, setTitle] = useState(animeEpisodes.episodes[0].title);

const [isVideoSkeletonVisible, setIsVideoSkeletonVisible] = useState(true);

Expand All @@ -102,7 +101,6 @@ export function WatchContainer({
<div className="flex-1 flex flex-col gap-6">
<VideoSettingsProvider>
<VideoContainer
title={title as string}
isVideoSkeletonVisible={isVideoSkeletonVisible}
handleVideoSkeletonVisibilty={setIsVideoSkeletonVisible}
currentEpisode={currentEpisode as string}
Expand All @@ -117,7 +115,6 @@ export function WatchContainer({
currentEpisode={currentEpisode as string}
handleCurrentEpisode={setCurrentEpisode}
handleVideoSkeletonVisibilty={setIsVideoSkeletonVisible}
handleTitle={setTitle}
/>
</div>
</div>
Expand Down

0 comments on commit 5c37ceb

Please sign in to comment.