From f6ecf3a393ba50bb74ce83ad2bc723e2670f7215 Mon Sep 17 00:00:00 2001 From: real-zephex Date: Fri, 12 Apr 2024 11:39:57 +0530 Subject: minor fixes --- src/app/kdrama/[id]/buttons.jsx | 8 +++++--- src/app/kdrama/[id]/page.jsx | 4 ++-- src/app/kdrama/components/cacher.js | 16 +++++++++++++++- src/app/kdrama/components/popular.jsx | 2 ++ src/app/kdrama/components/recent.jsx | 3 ++- src/app/kdrama/components/search.jsx | 4 +++- src/app/kdrama/styles/info.module.css | 1 - 7 files changed, 29 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/app/kdrama/[id]/buttons.jsx b/src/app/kdrama/[id]/buttons.jsx index c41c32f..a7d0f60 100644 --- a/src/app/kdrama/[id]/buttons.jsx +++ b/src/app/kdrama/[id]/buttons.jsx @@ -46,9 +46,11 @@ export default function EpisodesButtons({ data: episodeData, id: dramaId }) { episodeData.map((item, index) => ( diff --git a/src/app/kdrama/[id]/page.jsx b/src/app/kdrama/[id]/page.jsx index dce39ac..5625bd4 100644 --- a/src/app/kdrama/[id]/page.jsx +++ b/src/app/kdrama/[id]/page.jsx @@ -1,7 +1,7 @@ import styles from "../styles/info.module.css"; import Image from "next/image"; import EpisodesButtons from "./buttons"; -import PreFetchVideoLinks from "../components/cacher"; +import { PreFetchVideoLinks } from "../components/cacher"; export default async function DramaInfo({ params }) { const id = decodeURIComponent(params.id); @@ -62,7 +62,7 @@ export default async function DramaInfo({ params }) { async function getDramaInfo(id) { const res = await fetch( - `https://consumet-api-di2e.onrender.com/movies/dramacool/info?id=${id}`, + `https://consumet-jade.vercel.app/movies/dramacool/info?id=${id}`, { next: { revalidate: 86400 } } ); const data = await res.json(); diff --git a/src/app/kdrama/components/cacher.js b/src/app/kdrama/components/cacher.js index 4c787d5..1bb159e 100644 --- a/src/app/kdrama/components/cacher.js +++ b/src/app/kdrama/components/cacher.js @@ -1,7 +1,7 @@ // This function pre-fetches all the video links for a drama in the background "use server"; -export default async function PreFetchVideoLinks(data, dramaId) { +export async function PreFetchVideoLinks(data, dramaId) { try { const fetchPromises = data.map(async (element) => { const link = `https://consumet-jade.vercel.app/movies/dramacool/watch?episodeId=${element.id}&mediaId=${dramaId}`; @@ -14,3 +14,17 @@ export default async function PreFetchVideoLinks(data, dramaId) { console.error("Error occurred while pre-fetching video links:", error); } } + +export async function PreFetchAnimeInfo(data) { + try { + const fetchPromises = data.results.map(async (element) => { + const link = `https://consumet-jade.vercel.app/movies/dramacool/info?id=${element.id}`; + await fetch(link, { next: { revalidate: 86400 } }); + }); + + await Promise.all(fetchPromises); + console.log("Drama info fetched successfully."); + } catch (error) { + console.error("Error occurred while pre-fetching video links:", error); + } +} diff --git a/src/app/kdrama/components/popular.jsx b/src/app/kdrama/components/popular.jsx index 7c29ee2..639ed9f 100644 --- a/src/app/kdrama/components/popular.jsx +++ b/src/app/kdrama/components/popular.jsx @@ -1,9 +1,11 @@ import styles from "../styles/popular.module.css"; import Image from "next/image"; import Link from "next/link"; +import { PreFetchAnimeInfo } from "./cacher"; export default async function PopularDramas() { const popular = await getPopular(); + PreFetchAnimeInfo(popular); return (
diff --git a/src/app/kdrama/components/recent.jsx b/src/app/kdrama/components/recent.jsx index 0b6b7f6..e69e32a 100644 --- a/src/app/kdrama/components/recent.jsx +++ b/src/app/kdrama/components/recent.jsx @@ -1,10 +1,11 @@ import styles from "../styles/popular.module.css"; import Image from "next/image"; import Link from "next/link"; +import { PreFetchAnimeInfo } from "./cacher"; export default async function RecentDramas() { const popular = await getPopular(); - + PreFetchAnimeInfo(popular); return (

Recently Released

diff --git a/src/app/kdrama/components/search.jsx b/src/app/kdrama/components/search.jsx index 5444c89..0dac544 100644 --- a/src/app/kdrama/components/search.jsx +++ b/src/app/kdrama/components/search.jsx @@ -6,6 +6,7 @@ import { FaSearch } from "react-icons/fa"; import FetchSearchTitle from "./searchQuery"; import Image from "next/image"; import Link from "next/link"; +import { PreFetchAnimeInfo } from "./cacher"; export default function DramaSearch() { const [title, setTitle] = useState(""); @@ -15,6 +16,7 @@ export default function DramaSearch() { const handleSearch = async (title) => { setLoadingText(true); const data = await FetchSearchTitle(title); + PreFetchAnimeInfo(data); setLoadingText(false); setInfoTitle(data); }; @@ -32,7 +34,7 @@ export default function DramaSearch() { } }} > -
+
{loadingText && (

Wait a moment...

diff --git a/src/app/kdrama/styles/info.module.css b/src/app/kdrama/styles/info.module.css index 4b6a091..f61d90f 100644 --- a/src/app/kdrama/styles/info.module.css +++ b/src/app/kdrama/styles/info.module.css @@ -106,7 +106,6 @@ } .VideoPlayer { - height: auto; margin: 0px auto; } -- cgit v1.2.3