diff options
| author | Fuwn <[email protected]> | 2023-09-06 00:30:46 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-09-06 00:30:46 -0700 |
| commit | 19b51ab69176eb4f834c2c497f4c93a13779d7c7 (patch) | |
| tree | 2d21abd4c678f34f677a7c8ca625188d490c07cc /src/lib/List/WatchingAnimeList.svelte | |
| parent | feat(list): filter paused media (diff) | |
| download | due.moe-19b51ab69176eb4f834c2c497f4c93a13779d7c7.tar.xz due.moe-19b51ab69176eb4f834c2c497f4c93a13779d7c7.zip | |
feat(list): cache flattened
Diffstat (limited to 'src/lib/List/WatchingAnimeList.svelte')
| -rw-r--r-- | src/lib/List/WatchingAnimeList.svelte | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/lib/List/WatchingAnimeList.svelte b/src/lib/List/WatchingAnimeList.svelte index 52e3c505..fc8909c1 100644 --- a/src/lib/List/WatchingAnimeList.svelte +++ b/src/lib/List/WatchingAnimeList.svelte @@ -1,7 +1,7 @@ <script lang="ts"> /* eslint svelte/no-at-html-tags: "off" */ - import { mediaListCollection, Type, flattenLists, type Media } from '$lib/AniList/media'; + import { mediaListCollection, Type, type Media } from '$lib/AniList/media'; import type { UserIdentity, AniListAuthorisation } from '$lib/AniList/identity'; import { onMount } from 'svelte'; import anime from '../../stores/anime'; @@ -11,7 +11,7 @@ export let user: AniListAuthorisation; export let identity: UserIdentity; - let animeLists: Promise<{ entries: { media: Media }[] }[]>; + let animeLists: Promise<Media[]>; let startTime: number; let endTime: number; @@ -20,13 +20,12 @@ animeLists = mediaListCollection(user, identity, Type.Anime, $anime, $lastPruneTimes.anime); }); - const cleanMedia = (media: { entries: { media: Media }[] }[]) => { + const cleanMedia = (media: Media[]) => { if (media === undefined) { return []; } - const flattenedLists = flattenLists(media); - const releasingMedia = flattenedLists.filter( + const releasingMedia = media.filter( (media: Media) => media.status !== 'RELEASING' && media.status !== 'NOT_YET_RELEASED' && @@ -81,6 +80,17 @@ ); }); }; + + const cleanCache = () => { + animeLists = mediaListCollection( + user, + identity, + Type.Anime, + $anime, + $lastPruneTimes.anime, + true + ); + }; </script> {#await animeLists} @@ -95,6 +105,12 @@ <small style="opacity: 50%">{endTime / 1000}s</small></summary > + {#if cleanedMedia.length === 0} + <ul> + <li>No anime to display. <a href={'#'} on:click={cleanCache}>Force refresh</a></li> + </ul> + {/if} + <ul> {#each cleanedMedia as anime} <li> |