From 8cf0b363caf2c9dd3cb6b7214449be65c35332e3 Mon Sep 17 00:00:00 2001
From: ZXY101
Date: Thu, 14 Sep 2023 13:24:10 +0200
Subject: [PATCH] Fix catalog list issue when uploading
---
src/lib/components/Catalog.svelte | 6 +-----
src/lib/components/UploadModal.svelte | 13 ++++++++++---
src/lib/settings/index.ts | 2 --
src/lib/upload/index.ts | 2 +-
4 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/lib/components/Catalog.svelte b/src/lib/components/Catalog.svelte
index 9ea0aad..f30ad51 100644
--- a/src/lib/components/Catalog.svelte
+++ b/src/lib/components/Catalog.svelte
@@ -14,7 +14,7 @@
{#if $catalog.length > 0}
- {#each $catalog as { manga }}
+ {#each $catalog as { id, manga } (id)}
{/each}
@@ -39,8 +39,4 @@
text-align: center;
padding: 20px;
}
-
- a {
- color: $secondary-accent-color;
- }
diff --git a/src/lib/components/UploadModal.svelte b/src/lib/components/UploadModal.svelte
index 89d9057..a488066 100644
--- a/src/lib/components/UploadModal.svelte
+++ b/src/lib/components/UploadModal.svelte
@@ -5,6 +5,7 @@
import { onMount } from 'svelte';
import { scanFiles } from '$lib/upload';
import { formatBytes } from '$lib/util/upload';
+ import { catalog } from '$lib/catalog';
export let open = false;
@@ -40,8 +41,11 @@
let filePromises: Promise[];
let draggedFiles: File[] | undefined;
+ let loading = false;
+ $: disabled = loading || (!draggedFiles && !files);
const dropHandle = async (event: DragEvent) => {
+ loading = true;
draggedFiles = [];
filePromises = [];
event.preventDefault();
@@ -70,6 +74,8 @@
}
}
}
+
+ loading = false;
};
let defaultStyle =
@@ -125,6 +131,8 @@
Upload {draggedFiles.length} hih
{draggedFiles.length > 1 ? 'files' : 'file'}?
+ {:else if loading}
+
{:else}
Drag and drop / {storageSpace}
-
-
+
+
{/await}
diff --git a/src/lib/settings/index.ts b/src/lib/settings/index.ts
index 0005e4f..e321fbb 100644
--- a/src/lib/settings/index.ts
+++ b/src/lib/settings/index.ts
@@ -38,8 +38,6 @@ export function updateSetting(key: string, value: any) {
}
export function resetSettings() {
- console.log('br', defaultSettings);
-
settingsStore.set(defaultSettings);
}
diff --git a/src/lib/upload/index.ts b/src/lib/upload/index.ts
index 43a3bd5..ca57f2f 100644
--- a/src/lib/upload/index.ts
+++ b/src/lib/upload/index.ts
@@ -151,7 +151,7 @@ export async function processFiles(files: File[]) {
if (existingCatalog) {
await db.catalog.update(key, { manga: [...existingCatalog.manga, ...filtered] })
} else {
- await db.catalog.put({ id: key, manga: filtered })
+ await db.catalog.add({ id: key, manga: filtered })
}
}