From 93293176446dc4ccaf1576253f2bf43f5f4a051e Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Tue, 3 Oct 2023 20:43:49 -0700
Subject: feat(template): loading for initial load

---
 src/lib/List/Template/MangaListTemplate.svelte | 34 +++++++++++++++++---------
 1 file changed, 23 insertions(+), 11 deletions(-)

(limited to 'src/lib/List/Template/MangaListTemplate.svelte')

diff --git a/src/lib/List/Template/MangaListTemplate.svelte b/src/lib/List/Template/MangaListTemplate.svelte
index 904d14cf..75d12aa5 100644
--- a/src/lib/List/Template/MangaListTemplate.svelte
+++ b/src/lib/List/Template/MangaListTemplate.svelte
@@ -20,7 +20,7 @@
 	let startTime: number;
 	let endTime: number;
 	let lastUpdatedMedia = -1;
-	let previousMangaList: Media[] = [];
+	let previousMangaList: Media[];
 
 	const keyCacher = setInterval(() => {
 		startTime = performance.now();
@@ -137,16 +137,7 @@
 </script>
 
 {#await mangaLists}
-	<CleanMangaList
-		media={previousMangaList}
-		{cleanCache}
-		{endTime}
-		{lastUpdatedMedia}
-		{updateMedia}
-		disableIncrement
-	/>
-{:then media}
-	{#await cleanMedia(media, displayUnresolved)}
+	{#if previousMangaList}
 		<CleanMangaList
 			media={previousMangaList}
 			{cleanCache}
@@ -155,6 +146,27 @@
 			{updateMedia}
 			disableIncrement
 		/>
+	{:else}
+		<ListTitle />
+
+		<ul><li>Loading ...</li></ul>
+	{/if}
+{:then media}
+	{#await cleanMedia(media, displayUnresolved)}
+		{#if previousMangaList}
+			<CleanMangaList
+				media={previousMangaList}
+				{cleanCache}
+				{endTime}
+				{lastUpdatedMedia}
+				{updateMedia}
+				disableIncrement
+			/>
+		{:else}
+			<ListTitle />
+
+			<ul><li>Loading ...</li></ul>
+		{/if}
 	{:then cleanedMedia}
 		<CleanMangaList media={cleanedMedia} {cleanCache} {endTime} {lastUpdatedMedia} {updateMedia} />
 	{:catch}
-- 
cgit v1.2.3

