aboutsummaryrefslogtreecommitdiff
path: root/src/routes/settings/+page.svelte
blob: f50208b5e4966a7e9fcc4d8a82751964c24b5fe8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<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';
	import cacheMinutes from '../../stores/cacheMinutes';
	import roundDownChapters from '../../stores/roundDownChapters';

	export let data;

	$: displayingUnresolved = $displayUnresolved === 'true';
	$: roundingDownChapters = $roundDownChapters === '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}
	Please log in to modify settings.
{:else}
	<ul>
		<li>
			<a
				href="#"
				on:click={() =>
					displayingUnresolved ? displayUnresolved.set('false') : displayUnresolved.set('true')}
				>{displayingUnresolved ? 'Hide' : 'Show'} unresolved</a
			>
			<small style="opacity: 50%;">Displays unresolved chapter counts as "?"</small>
		</li>
		<li>
			<a
				href="#"
				on:click={() =>
					roundingDownChapters ? roundDownChapters.set('false') : roundDownChapters.set('true')}
				>{roundingDownChapters ? 'Round down' : 'Maintain'} chapters</a
			>
			<small style="opacity: 50%;">50/50.6 would <b>not</b> be due</small>
		</li>
		<li>
			<a
				href="#"
				on:click={() =>
					animeClosed ? closeAnimeByDefault.set('false') : closeAnimeByDefault.set('true')}
				>{animeClosed ? 'Expand' : 'Close'} anime panel by default</a
			>
		</li>
		<li>
			<a
				href="#"
				on:click={() =>
					mangaClosed ? closeMangaByDefault.set('false') : closeMangaByDefault.set('true')}
				>{mangaClosed ? 'Expand' : 'Close'} manga panel by default</a
			>
		</li>
		<li>
			<a href="#" on:click={pruneUnresolved}>Re-cache <b>ALL</b> unresolved manga</a>
		</li>
		<li><a href="#" on:click={pruneAll}>Re-cache <b>ALL</b> manga</a></li>
		<li>
			Re-cache <b>ALL</b> media keys every <input type="number" bind:value={$cacheMinutes} /> minutes
		</li>
		<li>
			Re-cache <b>ALL</b> manga chapter counts every
			<input type="number" bind:value={$cacheMangaMinutes} /> minutes
			<small style="opacity: 50%;"
				>Values may cause <a href="https://en.wikipedia.org/wiki/Rate_limiting"
					>rate-limiting depending on how much releasing manga are on your lists</a
				></small
			>
		</li>
	</ul>
{/if}