aboutsummaryrefslogtreecommitdiff
path: root/src/lib/List/Manga/CleanMangaList.svelte
blob: a41c89987d5d262ea59d30a913e0ba76049ab14b (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
81
82
83
84
<script lang="ts">
	import type { Media } from '$lib/AniList/media';
	import Error from '$lib/Error.svelte';
	import { volumeCount } from '$lib/Media/Manga/volumes';
	import { outboundLink } from '$lib/Media/links';
	import settings from '../../../stores/settings';
	// import ListTitle from '../ListTitle.svelte';
	import MediaTitle from '../MediaTitleDisplay.svelte';

	export let media: Media[];
	export let cleanCache: () => void;
	// export let endTime: number;
	export let lastUpdatedMedia: number;
	export let updateMedia: (
		id: number,
		progress: number | undefined,
		media: Media[]
	) => 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>
	</ul>
{/if}

<ul>
	{#each media as manga}
		{@const progress = (manga.mediaListEntry || { progress: 0 }).progress}

		{#if progress !== manga.episodes}
			<li>
				<a href={outboundLink(manga, 'manga', $settings.displayOutboundLinksTo)} target="_blank">
					<span
						style={lastUpdatedMedia === manga.id && manga.chapters !== progress
							? 'color: lightcoral'
							: ''}
					>
						<MediaTitle title={manga.title} />
					</span>
				</a>
				{#if $settings.displaySocialButton}
					[<a href={`https://anilist.co/manga/${manga.id}/social`} target="_blank">S</a>]
				{/if}
				<span style="opacity: 50%;">|</span>
				{pendingUpdate === manga.id ? progress + 1 : progress}{#if !due}
					<span style="opacity: 50%;">/{manga.chapters || '?'}</span>
				{/if}
				<a
					href={'#'}
					style={pendingUpdate === manga.id ? 'pointer-events: none; opacity: 50%;' : ''}
					on:click={() =>
						pendingUpdate === manga.id
							? null
							: updateMedia(manga.id, manga.mediaListEntry?.progress, media)}
				>
					+
				</a>
				{#if due || manga.episodes !== manga.chapters}
					[{manga.episodes || '?'}]
					{#await volumeCount(manga) then volumes}
						{@const volumeProgress = manga.mediaListEntry?.progressVolumes}
						{#if volumes !== null && (volumeProgress || 0) < volumes}
							<span style="color: lightcoral;">
								Vol. {volumeProgress} &#8594; {volumes}
							</span>
						{/if}
					{/await}
				{/if}
			</li>
		{/if}
	{/each}
</ul>