From bc986fb6efa925b2ef1e566ce20fa0aa4655f6aa Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Tue, 3 Oct 2023 14:43:05 -0700
Subject: feat(manga): no load on increment

---
 src/lib/List/CleanMangaList.svelte | 52 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 src/lib/List/CleanMangaList.svelte

(limited to 'src/lib/List/CleanMangaList.svelte')

diff --git a/src/lib/List/CleanMangaList.svelte b/src/lib/List/CleanMangaList.svelte
new file mode 100644
index 00000000..7d44732a
--- /dev/null
+++ b/src/lib/List/CleanMangaList.svelte
@@ -0,0 +1,52 @@
+<script lang="ts">
+	import type { Media } from '$lib/AniList/media';
+	import ListTitle from './ListTitle.svelte';
+
+	export let media: Media[];
+	export let cleanCache: () => Promise<void>;
+	export let endTime: number;
+	export let lastUpdatedMedia: number;
+	export let updateMedia: (
+		id: number,
+		progress: number | undefined,
+		media: Media[]
+	) => Promise<void>;
+	export let disableIncrement = false;
+</script>
+
+<ListTitle count={media.length} time={endTime / 1000}>
+	<a href={'#'} title="Force a refresh" on:click={cleanCache}>Force</a>
+</ListTitle>
+
+{#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}
+		<li>
+			<a href={`https://anilist.co/manga/${manga.id}`} target="_blank">
+				{#if lastUpdatedMedia === manga.id}
+					<span style="color: lightcoral">
+						{manga.title.english || manga.title.romaji || manga.title.native}
+					</span>
+				{:else}
+					{manga.title.english || manga.title.romaji || manga.title.native}
+				{/if}
+			</a>
+			<span style="opacity: 50%;">|</span>
+			{(manga.mediaListEntry || { progress: 0 }).progress}
+			<a
+				href={'#'}
+				style={disableIncrement ? 'pointer-events: none; opacity: 50%;' : ''}
+				on:click={() =>
+					disableIncrement ? null : updateMedia(manga.id, manga.mediaListEntry?.progress, media)}
+			>
+				+
+			</a>
+			[{manga.episodes || '?'}]
+		</li>
+	{/each}
+</ul>
-- 
cgit v1.2.3

