From 7acf5aef0db55bb4c70a822a092c4e3e7cd65f2a Mon Sep 17 00:00:00 2001 From: Cooper Ransom Date: Fri, 5 Apr 2024 13:30:06 -0400 Subject: [PATCH] Sexification is done :3 --- src/pages/Discover.tsx | 55 ++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/src/pages/Discover.tsx b/src/pages/Discover.tsx index 4338e951..36ab814e 100644 --- a/src/pages/Discover.tsx +++ b/src/pages/Discover.tsx @@ -72,11 +72,18 @@ export function Discover() { const bgColor = currentTheme?.extend?.colors?.background?.accentA ?? "#7831BF"; const navigate = useNavigate(); - - // Add a new state variable for the category movies const [categoryMovies, setCategoryMovies] = useState<{ [categoryName: string]: Movie[]; }>({}); + const [tvGenres, setTVGenres] = useState([]); + const [tvShowGenres, setTVShowGenres] = useState<{ + [genreId: number]: TVShow[]; + }>({}); + const carouselRef = useRef(null); + const carouselRefs = useRef<{ [key: string]: HTMLDivElement | null }>({}); + const gradientRef = useRef(null); + const [countdownTimeout, setCountdownTimeout] = + useState(null); useEffect(() => { const fetchMoviesForCategory = async (category: Category) => { @@ -100,14 +107,6 @@ export function Discover() { categories.forEach(fetchMoviesForCategory); }, []); - // Add a new state variable for the TV show genres - const [tvGenres, setTVGenres] = useState([]); - - // Add a new state variable for the TV shows - const [tvShowGenres, setTVShowGenres] = useState<{ - [genreId: number]: TVShow[]; - }>({}); - // Fetch TV show genres useEffect(() => { const fetchTVGenres = async () => { @@ -154,11 +153,6 @@ export function Discover() { tvGenres.forEach((genre) => fetchTVShowsForGenre(genre.id)); }, [tvGenres]); - // Move the hooks outside of the renderMovies function - const carouselRef = useRef(null); - const carouselRefs = useRef<{ [key: string]: HTMLDivElement | null }>({}); - const gradientRef = useRef(null); - // Update the scrollCarousel function to use the new ref map function scrollCarousel(categorySlug: string, direction: string) { const carousel = carouselRefs.current[categorySlug]; @@ -214,7 +208,7 @@ export function Discover() { gradientRef.current.style.top = `${carouselHeight}px`; gradientRef.current.style.bottom = `${carouselHeight}px`; } - }, [movieWidth]); // Added movieWidth to the dependency array + }, [movieWidth]); let isScrolling = false; @@ -279,7 +273,7 @@ export function Discover() { ); } - const [countdownTimeout, setCountdownTimeout] = - useState(null); const handleRandomMovieClick = () => { const allMovies = Object.values(genreMovies).flat(); // Flatten all movie arrays @@ -352,7 +345,7 @@ export function Discover() { setRandomMovie(selectedMovie); if (countdown !== null && countdown > 0) { - // Clear the countdown interval + // Clear the countdown setCountdown(null); if (countdownTimeout) { clearTimeout(countdownTimeout);