UPDATE/REFACTOR: Replace ContentContext with useContent hook;

REFACTOR: Add content type files;
This commit is contained in:
Chris-1010
2025-02-27 01:20:40 +00:00
parent 3f95b35acc
commit 74baa49c04
9 changed files with 178 additions and 158 deletions

View File

@@ -1,7 +1,7 @@
import React from "react";
import ListRow from "../components/Layout/ListRow";
import { useNavigate } from "react-router-dom";
import { useStreams, useCategories } from "../context/ContentContext";
import { useStreams, useCategories } from "../hooks/useContent";
import Button from "../components/Input/Button";
import DynamicPageContent from "../components/Layout/DynamicPageContent";
import LoadingScreen from "../components/Layout/LoadingScreen";
@@ -12,8 +12,8 @@ interface HomePageProps {
}
const HomePage: React.FC<HomePageProps> = ({ variant = "default" }) => {
const { streams } = useStreams();
const { categories } = useCategories();
const { streams, isLoading: isLoadingStreams } = useStreams();
const { categories, isLoading: isLoadingCategories } = useCategories();
const navigate = useNavigate();
const handleStreamClick = (streamerName: string) => {
@@ -24,9 +24,9 @@ const HomePage: React.FC<HomePageProps> = ({ variant = "default" }) => {
navigate(`/category/${categoryName}`);
};
if (!categories || categories.length === 0) {
console.log("No categories found yet");
return <LoadingScreen>Loading Categories...</LoadingScreen>;
if (isLoadingStreams || isLoadingCategories) {
console.log("No content found yet");
return <LoadingScreen>Loading Content...</LoadingScreen>;
}
return (
@@ -79,7 +79,7 @@ const HomePage: React.FC<HomePageProps> = ({ variant = "default" }) => {
Show More
</Button>
</ListRow>
<Footer/>
<Footer />
</DynamicPageContent>
);
};