From b89d0e7dada186e31be37e62a7a75efc2dbe9c99 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Sat, 26 Aug 2023 22:29:03 -0700
Subject: feat: initial build

---
 src/routes/settings/+page.svelte | 67 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
 create mode 100644 src/routes/settings/+page.svelte

(limited to 'src/routes/settings/+page.svelte')

diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte
new file mode 100644
index 00000000..cdd268f9
--- /dev/null
+++ b/src/routes/settings/+page.svelte
@@ -0,0 +1,67 @@
+<script lang="ts">
+	import displayUnresolved from '../../stores/displayUnresolved';
+	import closeAnimeByDefault from '../../stores/closeAnimeByDefault';
+	import closeMangaByDefault from '../../stores/closeMangaByDefault';
+	import { chapterDatabase } from '$lib/chapterDatabase';
+	import cacheMangaMinutes from '../../stores/cacheMangaMinutes';
+
+	export let data;
+
+	$: displayingUnresolved = $displayUnresolved === 'true';
+	$: mangaClosed = $closeMangaByDefault === 'true';
+	$: animeClosed = $closeAnimeByDefault === 'true';
+
+	const pruneUnresolved = async () => {
+		const unresolved = await chapterDatabase.chapters.where('chapters').equals(-1).toArray();
+
+		const ids = unresolved.map((m) => m.id);
+
+		await chapterDatabase.chapters.bulkDelete(ids);
+	};
+
+	const pruneAll = async () => {
+		const all = await chapterDatabase.chapters.toArray();
+
+		const ids = all.map((m) => m.id);
+
+		await chapterDatabase.chapters.bulkDelete(ids);
+	};
+</script>
+
+<a href="/">Home</a>
+
+<p />
+
+{#if data.user === undefined}
+	not
+{:else}
+	<ul>
+		<li>
+			<a
+				href="#"
+				on:click={() =>
+					displayingUnresolved ? displayUnresolved.set('false') : displayUnresolved.set('true')}
+				>{displayingUnresolved ? 'Hide' : 'Show'} unresolved</a
+			>
+		</li>
+		<li><a href="#" on:click={pruneUnresolved}>Prune cached, unresolved manga</a></li>
+		<li><a href="#" on:click={pruneAll}>Prune <b>ALL</b> cached manga</a></li>
+		<li>
+			<a
+				href="#"
+				on:click={() =>
+					animeClosed ? closeAnimeByDefault.set('false') : closeAnimeByDefault.set('true')}
+				>{animeClosed ? 'Close' : 'Expand'} anime by default</a
+			>
+		</li>
+		<li>
+			<a
+				href="#"
+				on:click={() =>
+					mangaClosed ? closeMangaByDefault.set('false') : closeMangaByDefault.set('true')}
+				>{mangaClosed ? 'Close' : 'Expand'} manga by default</a
+			>
+		</li>
+		<li>Re-cache manga every <input type="number" bind:value={$cacheMangaMinutes} /> minutes</li>
+	</ul>
+{/if}
-- 
cgit v1.2.3

