Skip to content

Commit

Permalink
feat: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Dovakiin0 committed Nov 19, 2024
1 parent 66702fd commit 06464e4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
docker rm kitsune-v2 || true
# Run the new container
docker run -d --name kitsune-v2 -e PORT=3000 -p 3000:3000 dovakiin0/kitsune-v2
docker run -d --name kitsune-v2 -p 4000:4000 dovakiin0/kitsune-v2
30 changes: 17 additions & 13 deletions src/hooks/use-get-last-episode-watched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ import { useState, useEffect } from "react";
import { IWatchedAnime } from "@/types/watched-anime";

export const useGetLastEpisodeWatched = (animeId: string) => {
const [lastEpisodeWatched, setLastEpisodeWatched] = useState<string | null>(null);
const [lastEpisodeWatched, setLastEpisodeWatched] = useState<string | null>(
null,
);

useEffect(() => {
const watchedDetails: Array<IWatchedAnime> =
JSON.parse(localStorage.getItem("watched") as string) || [];
useEffect(() => {
const watchedDetails: Array<IWatchedAnime> =
JSON.parse(localStorage.getItem("watched") as string) || [];

const anime = watchedDetails.find((watchedAnime) => watchedAnime.anime === animeId);
const anime = watchedDetails.find(
(watchedAnime) => watchedAnime.anime.id === animeId,
);

if (anime && anime.episodes.length > 0) {
const lastWatched = anime.episodes[anime.episodes.length - 1]; // Get the last episode
setLastEpisodeWatched(lastWatched);
} else {
setLastEpisodeWatched(null); // No episodes watched
}
}, [animeId]);
if (anime && anime.episodes.length > 0) {
const lastWatched = anime.episodes[anime.episodes.length - 1]; // Get the last episode
setLastEpisodeWatched(lastWatched);
} else {
setLastEpisodeWatched(null); // No episodes watched
}
}, [animeId]);

return lastEpisodeWatched;
return lastEpisodeWatched;
};
38 changes: 20 additions & 18 deletions src/hooks/use-is-anime-watched.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@ import { useState, useEffect } from "react";
import { IWatchedAnime } from "@/types/watched-anime";

export const useHasAnimeWatched = (animeId: string, episodeId?: string) => {
const [hasWatchedAnime, setHasWatchedAnime] = useState(false);
const [hasWatchedEpisode, setHasWatchedEpisode] = useState(false);
const [hasWatchedAnime, setHasWatchedAnime] = useState(false);
const [hasWatchedEpisode, setHasWatchedEpisode] = useState(false);

useEffect(() => {
const watchedDetails: Array<IWatchedAnime> =
JSON.parse(localStorage.getItem("watched") as string) || [];
useEffect(() => {
const watchedDetails: Array<IWatchedAnime> =
JSON.parse(localStorage.getItem("watched") as string) || [];

const anime = watchedDetails.find((watchedAnime) => watchedAnime.anime === animeId);
const anime = watchedDetails.find(
(watchedAnime) => watchedAnime.anime.id === animeId,
);

if (anime) {
setHasWatchedAnime(true); // Anime has been watched
if (episodeId) {
const episodeWatched = anime.episodes.includes(episodeId);
setHasWatchedEpisode(episodeWatched); // Set to true if the episode is watched
}
} else {
setHasWatchedAnime(false); // Anime has not been watched
setHasWatchedEpisode(false); // Episode has not been watched
}
}, [animeId, episodeId]);
if (anime) {
setHasWatchedAnime(true); // Anime has been watched
if (episodeId) {
const episodeWatched = anime.episodes.includes(episodeId);
setHasWatchedEpisode(episodeWatched); // Set to true if the episode is watched
}
} else {
setHasWatchedAnime(false); // Anime has not been watched
setHasWatchedEpisode(false); // Episode has not been watched
}
}, [animeId, episodeId]);

return { hasWatchedAnime, hasWatchedEpisode };
return { hasWatchedAnime, hasWatchedEpisode };
};

0 comments on commit 06464e4

Please sign in to comment.