diff options
| author | real-zephex <[email protected]> | 2024-04-18 21:43:02 +0530 |
|---|---|---|
| committer | real-zephex <[email protected]> | 2024-04-18 21:43:02 +0530 |
| commit | ec888b9bec997456368d03579e569929f3745307 (patch) | |
| tree | 0932acf009654212c4fe4663858482cd22ab7bd8 /src/app/manga/cacher.js | |
| parent | minor fixes (diff) | |
| download | dramalama-ec888b9bec997456368d03579e569929f3745307.tar.xz dramalama-ec888b9bec997456368d03579e569929f3745307.zip | |
feature added: tracker for mangas
Diffstat (limited to 'src/app/manga/cacher.js')
| -rw-r--r-- | src/app/manga/cacher.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/app/manga/cacher.js b/src/app/manga/cacher.js index 916caca..7f047ab 100644 --- a/src/app/manga/cacher.js +++ b/src/app/manga/cacher.js @@ -1,7 +1,7 @@ // This function pre-fetches all the chapter pages links for a manga in the background "use server"; -export default async function PreFetchChaterLinks(data) { +export async function PreFetchChaterLinks(data) { try { const fetchPromises = data.map(async (element) => { const link = `https://consumet-jade.vercel.app/meta/anilist-manga/read?chapterId=${element.id}&provider=mangadex`; @@ -17,3 +17,16 @@ export default async function PreFetchChaterLinks(data) { ); } } + +export async function PreFetchMangaInfo(data) { + try { + const fetchPromises = data.results.map(async (element) => { + const link = `https://consumet-jade.vercel.app/meta/anilist-manga/${element.id}?provider=mangadex`; + await fetch(link, { next: { revalidate: 86400 } }); + }); + await Promise.all(fetchPromises); + console.log("Manga info pre-fetched successfully!"); + } catch (error) { + console.error("error", error); + } +} |