aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Tools/SequelCatcher/Tool.svelte
blob: 06d635b3061bcc6c1af6e6bf8b8917ce449bd36d (plain) (blame)
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
<script lang="ts">
	import List from './List.svelte';
	import type { AniListAuthorisation } from '$lib/Data/AniList/identity';
	import userIdentity from '$stores/identity';
	import { type Media, mediaListCollection, Type } from '$lib/Data/AniList/media';
	import LogInRestricted from '$lib/Error/LogInRestricted.svelte';
	import anime from '$stores/anime';
	import identity from '$stores/identity';
	import { onMount } from 'svelte';
	import lastPruneTimes from '$stores/lastPruneTimes';
	import Message from '$lib/Loading/Message.svelte';
	import Skeleton from '$lib/Loading/Skeleton.svelte';
	import Username from '$lib/Layout/Username.svelte';

	export let user: AniListAuthorisation;

	let mediaList: Promise<Media[]>;

	onMount(async () => {
		if (user === undefined || $identity.id === -2) return;

		mediaList = mediaListCollection(
			user,
			$userIdentity,
			Type.Anime,
			$anime,
			$lastPruneTimes.anime,
			{
				forcePrune: true,
				includeCompleted: true,
				all: true,
				includeRelations: true
			}
		);
	});
</script>

{#if user === undefined || $identity.id === -2}
	<LogInRestricted />
{:else}
	<div class="card">
		{#await mediaList}
			<Message message="Cross-checking media ..." />

			<Skeleton
				card={false}
				count={8}
				pad={false}
				height={'0.9rem'}
				width={'100%'}
				list
				grid={false}
			/>
		{:then mediaListUnchecked}
			{#if mediaListUnchecked}
				<List {mediaListUnchecked} />
			{:else}
				<Message message="Cross-checking media ..." />

				<Skeleton
					card={false}
					count={8}
					pad={false}
					height={'0.9rem'}
					width={'100%'}
					list
					grid={false}
				/>
			{/if}
		{:catch}
			<Message message="" loader="ripple" slot withReload fullscreen>Error fetching media.</Message>
		{/await}

		<p />

		<blockquote style="margin: 0 0 0 1.5rem;">
			Thanks to <Username username="sevengirl" /> and <Username username="esthereae" /> for the idea!
		</blockquote>
	</div>
{/if}