Clear progress on delete

This commit is contained in:
ZXY101
2023-10-03 12:55:20 +02:00
parent 316b99c20f
commit f09d48f702
3 changed files with 24 additions and 2 deletions

View File

@@ -3,9 +3,15 @@
import { db } from '$lib/catalog/db'; import { db } from '$lib/catalog/db';
import { promptConfirmation } from '$lib/util'; import { promptConfirmation } from '$lib/util';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
import { clearVolumes } from '$lib/settings';
function onConfirm() {
clearVolumes();
db.catalog.clear();
}
function onClear() { function onClear() {
promptConfirmation('Are you sure you want to clear your catalog?', () => db.catalog.clear()); promptConfirmation('Are you sure you want to clear your catalog?', onConfirm);
goto('/'); goto('/');
} }
</script> </script>

View File

@@ -44,6 +44,17 @@ export function initializeVolume(volume: string) {
}); });
} }
export function deleteVolume(volume: string) {
volumes.update((prev) => {
delete prev[volume]
return prev
})
}
export function clearVolumes() {
volumes.set({});
}
export function updateProgress(volume: string, progress: number, chars: number, completed = false) { export function updateProgress(volume: string, progress: number, chars: number, completed = false) {
volumes.update((prev) => { volumes.update((prev) => {
return { return {

View File

@@ -7,7 +7,7 @@
import { promptConfirmation } from '$lib/util'; import { promptConfirmation } from '$lib/util';
import { page } from '$app/stores'; import { page } from '$app/stores';
import type { Volume } from '$lib/types'; import type { Volume } from '$lib/types';
import { onMount } from 'svelte'; import { deleteVolume } from '$lib/settings';
function sortManga(a: Volume, b: Volume) { function sortManga(a: Volume, b: Volume) {
if (a.volumeName < b.volumeName) { if (a.volumeName < b.volumeName) {
@@ -23,6 +23,11 @@
async function confirmDelete() { async function confirmDelete() {
const title = manga?.[0].mokuroData.title_uuid; const title = manga?.[0].mokuroData.title_uuid;
manga?.forEach((vol) => {
const volId = vol.mokuroData.volume_uuid;
deleteVolume(volId);
});
await db.catalog.delete(title); await db.catalog.delete(title);
goto('/'); goto('/');
} }