diff options
| author | real-zephex <[email protected]> | 2024-04-12 11:39:57 +0530 |
|---|---|---|
| committer | real-zephex <[email protected]> | 2024-04-12 11:39:57 +0530 |
| commit | f6ecf3a393ba50bb74ce83ad2bc723e2670f7215 (patch) | |
| tree | 676f00108119d29253ffe0b658c62575788199e4 /src | |
| parent | fix: fixed kdrama page and made it available (diff) | |
| download | dramalama-f6ecf3a393ba50bb74ce83ad2bc723e2670f7215.tar.xz dramalama-f6ecf3a393ba50bb74ce83ad2bc723e2670f7215.zip | |
minor fixes
Diffstat (limited to 'src')
| -rw-r--r-- | src/app/kdrama/[id]/buttons.jsx | 8 | ||||
| -rw-r--r-- | src/app/kdrama/[id]/page.jsx | 4 | ||||
| -rw-r--r-- | src/app/kdrama/components/cacher.js | 16 | ||||
| -rw-r--r-- | src/app/kdrama/components/popular.jsx | 2 | ||||
| -rw-r--r-- | src/app/kdrama/components/recent.jsx | 3 | ||||
| -rw-r--r-- | src/app/kdrama/components/search.jsx | 4 | ||||
| -rw-r--r-- | src/app/kdrama/styles/info.module.css | 1 |
7 files changed, 29 insertions, 9 deletions
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) => ( <button key={index} - onClick={() => - test(item.id, dramaId, item.title) - } + onClick={(event) => { + test(item.id, dramaId, item.title); + event.target.style.backgroundColor = + "var(--soft-purple)"; + }} > {item.title} </button> 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 ( <div className={styles.Main}> 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 ( <div className={styles.Main}> <p className={styles.popDramasText}>Recently Released</p> 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() { } }} ></input> - </div> + </div> {loadingText && ( <p className={styles.LoadingText}>Wait a moment...</p> 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; } |