From 7fc05993446392f5342815734a7a2e99cf63bddb Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sun, 27 Aug 2023 17:22:40 -0700
Subject: feat: cache media

---
 src/lib/List/Due/MangaList.svelte | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

(limited to 'src/lib/List/Due/MangaList.svelte')

diff --git a/src/lib/List/Due/MangaList.svelte b/src/lib/List/Due/MangaList.svelte
index 936d310a..c7f58819 100644
--- a/src/lib/List/Due/MangaList.svelte
+++ b/src/lib/List/Due/MangaList.svelte
@@ -3,8 +3,8 @@
 	import type { UserIdentity, AniListAuthorisation } from '$lib/AniList/identity';
 	import { onMount } from 'svelte';
 	import { chapterCount } from '$lib/mangadex';
-	import lastPruneAt from '../../../stores/lastPruneAt';
-	import cacheMangaMinutes from '../../../stores/cacheMangaMinutes';
+	import mangaLastPrune from '../../../stores/mangaLastPrune';
+	import manga from '../../../stores/manga';
 
 	export let user: AniListAuthorisation;
 	export let identity: UserIdentity;
@@ -16,7 +16,7 @@
 
 	onMount(async () => {
 		startTime = performance.now();
-		mangaLists = mediaListCollection(user, identity, Type.Manga);
+		mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $mangaLastPrune);
 	});
 
 	const cleanMedia = async (media: object[][], displayUnresolved: boolean) => {
@@ -24,13 +24,13 @@
 			return [];
 		}
 
-		if ($lastPruneAt == '') {
-			lastPruneAt.set(new Date().getTime().toString());
-		} else {
-			if ((new Date().getTime() - Number($lastPruneAt)) / 1000 / 60 > Number($cacheMangaMinutes)) {
-				lastPruneAt.set(new Date().getTime().toString());
-			}
-		}
+		// if ($lastPruneAt == '') {
+		// 	lastPruneAt.set(new Date().getTime().toString());
+		// } else {
+		// 	if ((new Date().getTime() - Number($lastPruneAt)) / 1000 / 60 > Number($cacheMangaMinutes)) {
+		// 		lastPruneAt.set(new Date().getTime().toString());
+		// 	}
+		// }
 
 		const flattenedLists = flattenLists(media);
 		const releasingMedia = flattenedLists.filter(
@@ -76,7 +76,7 @@
 	};
 
 	const updateMedia = async (id: number, progress: number | undefined) => {
-		mangaLists = mediaListCollection(user, identity, Type.Manga);
+		mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $mangaLastPrune);
 
 		await fetch(`/anilist/increment?id=${id}&progress=${progress! + 1}`);
 	};
-- 
cgit v1.2.3

