aboutsummaryrefslogtreecommitdiff
path: root/src/app/manga/cacher.js
diff options
context:
space:
mode:
authorreal-zephex <[email protected]>2024-04-08 16:57:21 +0530
committerreal-zephex <[email protected]>2024-04-08 16:57:21 +0530
commit9e42f2f67189845c6a88151743f30ad10a73a689 (patch)
tree0467fc9539787ce1b1a0423adc9b9b0231090315 /src/app/manga/cacher.js
parentsmall chanegs here and there, manga and anime pages are currently broken. cha... (diff)
downloaddramalama-9e42f2f67189845c6a88151743f30ad10a73a689.tar.xz
dramalama-9e42f2f67189845c6a88151743f30ad10a73a689.zip
prolly the last update to dramalama.
Diffstat (limited to 'src/app/manga/cacher.js')
-rw-r--r--src/app/manga/cacher.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/app/manga/cacher.js b/src/app/manga/cacher.js
new file mode 100644
index 0000000..ef8ef2e
--- /dev/null
+++ b/src/app/manga/cacher.js
@@ -0,0 +1,19 @@
+// This function pre-fetches all the chapter pages links for a manga in the background
+"use server";
+
+export default async function PreFetchChaterLinks(data) {
+ try {
+ const fetchPromises = data.map(async (element) => {
+ const link = `https://consumet-api-di2e.onrender.com/meta/anilist-manga/read?chapterId=${element.id}&provider=mangadex`;
+ await fetch(link, { cache: "force-cache" });
+ });
+
+ await Promise.all(fetchPromises);
+ console.log("Chapter links pre-fetched successfully!");
+ } catch (error) {
+ console.error(
+ "Error occurred while pre-fetching chapter links:",
+ error
+ );
+ }
+}