1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
<script lang="ts">
/* eslint svelte/no-at-html-tags: "off" */
import type { AniListAuthorisation } from '$lib/Data/AniList/identity';
import type { Media } from '$lib/Data/AniList/media';
import Error from '$lib/Error/RateLimited.svelte';
import settings from '$stores/settings';
import CleanAnimeList from './CleanAnimeList.svelte';
import ListTitle from '../ListTitle.svelte';
import type { SubsPlease } from '$lib/Media/Anime/Airing/Subtitled/subsPlease';
import PlaceholderList from './PlaceholderList.svelte';
import { browser } from '$app/environment';
import { onMount } from 'svelte';
import subsPlease from '$stores/subsPlease';
import identity from '$stores/identity';
interface Props {
endTime: number;
cleanMedia: (
media: Media[],
displayUnresolved: boolean,
subsPlease: SubsPlease | null,
plannedOnly?: boolean
) => Media[];
animeLists: Promise<Media[]>;
user: AniListAuthorisation;
title: any;
completed?: boolean;
plannedOnly?: boolean;
upcoming?: boolean;
notYetReleased?: boolean;
dummy?: boolean;
}
let {
endTime,
cleanMedia,
animeLists = $bindable(),
user,
title,
completed = false,
plannedOnly = false,
upcoming = false,
notYetReleased = false,
dummy = false
}: Props = $props();
let lastUpdatedMedia = $state(-1);
let previousAnimeList: Media[] = $state();
let pendingUpdate: number | null = $state(null);
let lastListSize = $state(8);
onMount(() => {
if (browser) {
const lastStoredList = localStorage.getItem(
`last${
notYetReleased ? 'NotYetReleased' : upcoming ? 'Upcoming' : completed ? 'Completed' : ''
}AnimeListLength`
);
if (lastStoredList) lastListSize = parseInt(lastStoredList);
}
});
</script>
{#if !$subsPlease && !dummy}
<PlaceholderList count={lastListSize} {title} />
{:else}
{#await animeLists}
{#if previousAnimeList}
<CleanAnimeList
media={previousAnimeList}
{title}
bind:animeLists
{user}
{endTime}
bind:lastUpdatedMedia
{completed}
{notYetReleased}
{upcoming}
bind:previousAnimeList
bind:pendingUpdate
{dummy}
/>
{:else}
<PlaceholderList count={lastListSize} {title} />
{/if}
{:then media}
{#if $identity.id === -2 && !dummy}
<PlaceholderList count={lastListSize} {title} />
{:else}
<CleanAnimeList
media={cleanMedia(media, $settings.displayUnresolved, $subsPlease, plannedOnly)}
{title}
bind:animeLists
{user}
{endTime}
bind:lastUpdatedMedia
{completed}
{notYetReleased}
{upcoming}
bind:previousAnimeList
bind:pendingUpdate
{dummy}
/>
{/if}
{:catch}
<ListTitle time={0} count={-1337} {title} />
<Error />
{/await}
{/if}
|