aboutsummaryrefslogtreecommitdiff
path: root/src/lib/List/Due/MangaList.svelte
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-09-02 10:08:34 -0700
committerFuwn <[email protected]>2023-09-02 10:08:34 -0700
commit9a72bbdb41a3ef663aeba563b5061fb5c48c4b65 (patch)
tree204b946ea2e619a75a9b87edd0a75257f613155f /src/lib/List/Due/MangaList.svelte
parentfeat(settings): nicer settings page (diff)
downloaddue.moe-9a72bbdb41a3ef663aeba563b5061fb5c48c4b65.tar.xz
due.moe-9a72bbdb41a3ef663aeba563b5061fb5c48c4b65.zip
feat(due): background cache
Diffstat (limited to 'src/lib/List/Due/MangaList.svelte')
-rw-r--r--src/lib/List/Due/MangaList.svelte15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/lib/List/Due/MangaList.svelte b/src/lib/List/Due/MangaList.svelte
index 6056b9eb..53ab5823 100644
--- a/src/lib/List/Due/MangaList.svelte
+++ b/src/lib/List/Due/MangaList.svelte
@@ -1,7 +1,7 @@
<script lang="ts">
import { mediaListCollection, Type, flattenLists, type Media } from '$lib/AniList/media';
import type { UserIdentity, AniListAuthorisation } from '$lib/AniList/identity';
- import { onMount } from 'svelte';
+ import { onDestroy, onMount } from 'svelte';
import { chapterCount } from '$lib/mangadex';
import chaptersLastPrune from '../../../stores/chaptersLastPrune';
import manga from '../../../stores/manga';
@@ -10,6 +10,7 @@
import roundDownChapters from '../../../stores/roundDownChapters';
import mangaLastPrune from '../../../stores/mangaLastPrune';
import displayNotStarted from '../../../stores/displayNotStarted';
+ import cacheMinutes from '../../../stores/cacheMinutes';
export let user: AniListAuthorisation;
export let identity: UserIdentity;
@@ -19,11 +20,21 @@
let startTime: number;
let endTime: number;
+ const keyCacher = setInterval(() => {
+ startTime = performance.now();
+ endTime = -1;
+ mangaLists = mediaListCollection(user, identity, Type.Anime, $manga, $mangaLastPrune, true);
+ }, Number($cacheMinutes || 30) * 1000 * 60);
+
onMount(async () => {
startTime = performance.now();
mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $mangaLastPrune);
});
+ onDestroy(() => {
+ clearInterval(keyCacher);
+ });
+
const cleanMedia = async (
media: { entries: { media: Media }[] }[],
displayUnresolved: boolean
@@ -88,7 +99,7 @@
);
});
- if (!endTime) {
+ if (!endTime || endTime === -1) {
endTime = performance.now() - startTime;
}