aboutsummaryrefslogtreecommitdiff
path: root/src/app/anime/components/cacher.js
diff options
context:
space:
mode:
authorreal-zephex <[email protected]>2024-05-11 01:33:00 +0530
committerreal-zephex <[email protected]>2024-05-11 01:33:00 +0530
commit4c4f8214637ac8d19e16f71d20542982a5eedad7 (patch)
treed59021d92da577b2c38bc591571fe13a35a3b779 /src/app/anime/components/cacher.js
parentMerge pull request #24 from zephex-alt/master (diff)
downloaddramalama-4c4f8214637ac8d19e16f71d20542982a5eedad7.tar.xz
dramalama-4c4f8214637ac8d19e16f71d20542982a5eedad7.zip
UI changes, Logic change and complete re-write for anime page
Diffstat (limited to 'src/app/anime/components/cacher.js')
-rw-r--r--src/app/anime/components/cacher.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/app/anime/components/cacher.js b/src/app/anime/components/cacher.js
new file mode 100644
index 0000000..acc780a
--- /dev/null
+++ b/src/app/anime/components/cacher.js
@@ -0,0 +1,29 @@
+"use server";
+
+import { info_url, watch_url } from "../../../../utils/anime_urls";
+
+export async function preFetchAnimeInfo(data) {
+ try {
+ const fetchPromises = data.results.map(async (element) => {
+ await fetch(info_url(element.id), { next: { revalidate: 21600 } });
+ });
+
+ await Promise.all(fetchPromises);
+ console.log("Anime info pre-fetched successfully!");
+ } catch (error) {
+ console.error("Error occurred while pre-fetching anime info: ", error);
+ }
+}
+
+export async function preFetchVideoLinks(data) {
+ try {
+ const fetchPromises = data.episodes.map(async (element) => {
+ await fetch(watch_url(element.id), { next: { revalidate: 21600 } });
+ });
+
+ await Promise.all(fetchPromises);
+ console.log("Anime video links info pre-fetched successfully!");
+ } catch (error) {
+ console.error("Error occurred while pre-fetching anime info: ", error);
+ }
+}