aboutsummaryrefslogtreecommitdiff
path: root/src/lib/List/Manga
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-03-01 14:20:08 -0800
committerFuwn <[email protected]>2026-03-01 15:24:03 -0800
commit3b10a1f47fd5838fe3b94c19673a52610b88cf1e (patch)
treed468a1fc12290e38686b255194ff6596b58cbf01 /src/lib/List/Manga
parentperf(match): fast-path exact normalised title matches (diff)
downloaddue.moe-3b10a1f47fd5838fe3b94c19673a52610b88cf1e.tar.xz
due.moe-3b10a1f47fd5838fe3b94c19673a52610b88cf1e.zip
perf: optimise list hot paths and shared timers
Diffstat (limited to 'src/lib/List/Manga')
-rw-r--r--src/lib/List/Manga/MangaListTemplate.svelte45
1 files changed, 33 insertions, 12 deletions
diff --git a/src/lib/List/Manga/MangaListTemplate.svelte b/src/lib/List/Manga/MangaListTemplate.svelte
index c2fc0513..f549496d 100644
--- a/src/lib/List/Manga/MangaListTemplate.svelte
+++ b/src/lib/List/Manga/MangaListTemplate.svelte
@@ -45,19 +45,35 @@
let rateLimited = false;
let forceFlag = false;
let lastListSize = 5;
-
- const keyCacher = setInterval(
- () => {
- startTime = performance.now();
- endTime = -1;
- mangaLists = mediaListCollection(user, $identity, Type.Manga, $manga, $lastPruneTimes.manga, {
- addNotification
- });
- },
- $settings.cacheMinutes * 1000 * 60
- );
+ let keyCacher: ReturnType<typeof setInterval> | undefined;
+ let keyCacheMinutes = -1;
+
+ const restartKeyCacher = (cacheMinutes: number) => {
+ if (keyCacher) clearInterval(keyCacher);
+
+ keyCacheMinutes = cacheMinutes;
+ keyCacher = setInterval(
+ () => {
+ startTime = performance.now();
+ endTime = -1;
+ mangaLists = mediaListCollection(
+ user,
+ $identity,
+ Type.Manga,
+ $manga,
+ $lastPruneTimes.manga,
+ {
+ addNotification
+ }
+ );
+ },
+ cacheMinutes * 1000 * 60
+ );
+ };
onMount(async () => {
+ restartKeyCacher(Math.max($settings.cacheMangaMinutes, 5));
+
if (browser) {
const lastStoredList = (await localforage.getItem(
`last${due ? '' : 'Completed'}MangaListLength`
@@ -96,7 +112,12 @@
}
});
- onDestroy(() => clearInterval(keyCacher));
+ $: if (keyCacher && keyCacheMinutes !== Math.max($settings.cacheMangaMinutes, 5))
+ restartKeyCacher(Math.max($settings.cacheMangaMinutes, 5));
+
+ onDestroy(() => {
+ if (keyCacher) clearInterval(keyCacher);
+ });
const cleanMedia = async (manga: Media[], displayUnresolved: boolean, force: boolean) => {
progress = 0;