diff options
| author | Fuwn <[email protected]> | 2023-12-10 02:19:28 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-10 02:34:52 -0800 |
| commit | e8bf266e5f487f7c444baf16bbabf1f4e4c2bdad (patch) | |
| tree | 7dff6a98a33392670e8b0085d7ea98904d1420a2 /src/lib/List | |
| parent | feat(page): use video always (diff) | |
| download | due.moe-e8bf266e5f487f7c444baf16bbabf1f4e4c2bdad.tar.xz due.moe-e8bf266e5f487f7c444baf16bbabf1f4e4c2bdad.zip | |
feat(mangadex): add safe rate limits
Diffstat (limited to 'src/lib/List')
| -rw-r--r-- | src/lib/List/Manga/CleanMangaList.svelte | 6 | ||||
| -rw-r--r-- | src/lib/List/Manga/MangaListTemplate.svelte | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/List/Manga/CleanMangaList.svelte b/src/lib/List/Manga/CleanMangaList.svelte index 8f36f244..40082809 100644 --- a/src/lib/List/Manga/CleanMangaList.svelte +++ b/src/lib/List/Manga/CleanMangaList.svelte @@ -1,5 +1,6 @@ <script lang="ts"> import type { Media } from '$lib/AniList/media'; + import Error from '$lib/Error.svelte'; import { volumeCount } from '$lib/Media/manga'; import { outboundLink } from '$lib/Media/media'; import settings from '../../../stores/settings'; @@ -17,12 +18,17 @@ ) => Promise<void>; export let pendingUpdate: number | null; export let due: boolean; + export let rateLimited: boolean; </script> <ListTitle count={media.length} time={endTime / 1000}> <a href={'#'} title="Force a full refresh" on:click={cleanCache}>Refresh</a> </ListTitle> +{#if rateLimited} + <Error /> +{/if} + {#if media.length === 0} <ul> <li>No manga to display. <a href={'#'} on:click={cleanCache}>Force refresh</a></li> diff --git a/src/lib/List/Manga/MangaListTemplate.svelte b/src/lib/List/Manga/MangaListTemplate.svelte index 370cfd72..c6ea8b7d 100644 --- a/src/lib/List/Manga/MangaListTemplate.svelte +++ b/src/lib/List/Manga/MangaListTemplate.svelte @@ -23,6 +23,7 @@ let previousMangaList: Media[]; let pendingUpdate: number | null = null; let progress = 0; + let rateLimited = false; const keyCacher = setInterval(() => { startTime = performance.now(); @@ -84,7 +85,15 @@ const chapterCounts: (number | null)[] = []; for (let i = 0; i < chapterPromises.length; i++) { - chapterCounts.push(await chapterPromises[i]); + const count = await chapterPromises[i]; + + if (count === -22) { + rateLimited = true; + + break; + } + + chapterCounts.push(count); progress += progressStep; } @@ -168,6 +177,7 @@ {updateMedia} {pendingUpdate} {due} + {rateLimited} /> {:else} <ListTitle /> @@ -185,6 +195,7 @@ {updateMedia} {pendingUpdate} {due} + {rateLimited} /> {:else} <ListTitle /> @@ -200,6 +211,7 @@ {updateMedia} {pendingUpdate} {due} + {rateLimited} /> {:catch} <ListTitle count={-1337} time={0} /> |