blob: ecf7fa5a393b36e7a2b0e7e0e550fa98a7cc58ea (
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
<script lang="ts">
import Spacer from '$lib/Layout/Spacer.svelte';
import type { Media } from '$lib/Data/AniList/media';
import Error from '$lib/Error/RateLimited.svelte';
import { volumeCount } from '$lib/Media/Manga/volumes';
import settings from '$stores/settings';
import ListTitle from '../ListTitle.svelte';
import { onMount } from 'svelte';
import root from '$lib/Utility/root';
import locale from '$stores/locale';
import Skeleton from '$lib/Loading/Skeleton.svelte';
import { browser } from '$app/environment';
import proxy from '$lib/Utility/proxy';
import '../covers.css';
import CleanGrid from '../CleanGrid.svelte';
import CleanList from '../CleanList.svelte';
import stateBin from '$stores/stateBin';
import localforage from 'localforage';
export let media: Media[];
export let cleanCache: () => void;
export let endTime: number;
export let lastUpdatedMedia: number;
export let updateMedia: (
id: number,
progress: number | undefined,
media: Media[]
) => Promise<void>;
export let pendingUpdate: number | null;
export let due: boolean;
export let rateLimited: boolean;
export let authorised: boolean;
export let dummy = false;
export let disableFilter = false;
let serviceStatusResponse: Promise<Response>;
let totalEpisodeDueCount = media
.map((manga) => {
if ($settings.displayTotalEpisodes && !$settings.displayTotalDueEpisodes) return 1;
if (!due && !$settings.displayTotalEpisodes) return 1;
return (manga.episodes || 1) - (manga.mediaListEntry?.progress || 0);
})
.reduce((a, b) => a + b, 0);
const lists = Array.from(
new Set(
media
.flatMap((m) => Object.entries(m.mediaListEntry?.customLists ?? {}))
.filter(([_, value]) => value)
.map(([key]) => key)
)
);
const filterKind = due ? 'due' : 'completed';
const filterKey = `${filterKind}MangaListFilter`;
$: selectedList = disableFilter ? 'All' : ($stateBin[filterKey] as string) || 'All';
$: filteredMedia =
selectedList === 'All' || !$settings.displayMediaListFilter
? media
: media.filter((m) => m.mediaListEntry?.customLists?.[selectedList]);
onMount(async () => {
serviceStatusResponse = fetch(proxy('https://api.mangadex.org/ping'));
if (browser)
await localforage.setItem(
`last${due ? '' : 'Completed'}MangaListLength`,
media.length.toString()
);
});
const increment = (manga: Media) => {
if (!(pendingUpdate === manga.id || dummy))
updateMedia(manga.id, manga.mediaListEntry?.progress, media);
};
</script>
{#if authorised}
<ListTitle
count={$settings.displayTotalDueEpisodes || $settings.displayTotalEpisodes
? totalEpisodeDueCount
: filteredMedia.length}
time={endTime / 1000}
title={due
? $locale().lists.due.mangaAndLightNovels
: $locale().lists.completed.mangaAndLightNovels}
hideTime={dummy}
hideCount={dummy}
>
{#if !dummy}
<button
class="small-button"
title="Force a full refresh"
onclick={cleanCache}
data-umami-event="Force Refresh Manga">Refresh</button
>
{/if}
</ListTitle>
{/if}
{#if rateLimited}
{#await serviceStatusResponse}
<Skeleton card={false} count={1} height="0.9rem" list />
{:then status}
{#if status}
{#if status.status === 503}
<a href="https://due.moe">due.moe</a>'s manga data source is currently down for maintenance.
Please check back later.
{:else if status.status !== 200}
<a href="https://due.moe">due.moe</a>'s manga data source is currently unavailable. Please
check back later.
{:else}
<Error />
{/if}
{:else}
<Skeleton card={false} count={1} height="0.9rem" list />
{/if}
{:catch}
<a href="https://due.moe">due.moe</a>'s manga data source is currently unreachable. Please check
back later.
{/await}
{/if}
{#if media.length === 0 && !rateLimited}
{#if rateLimited}
<Spacer />
{/if}
<p>
No manga to display. <button onclick={cleanCache} data-umami-event="Force Refresh No Manga"
>Force refresh</button
>
</p>
<span>
Don't read manga? <button
onclick={() => ($settings.disableManga = true)}
data-umami-event="Disable No Manga">Hide the manga panel</button
>
You can re-enable it later in the <a href={root('/settings')}>Settings</a>.
</span>
{:else if $settings.displayMediaListFilter && !disableFilter}
<select bind:value={$stateBin[filterKey]}>
<option value="All">All</option>
{#each lists as list}
<option value={list}>{list}</option>
{/each}
</select>
<Spacer />
{/if}
{#if $settings.displayCoverModeManga || dummy}
<CleanGrid media={filteredMedia} {dummy} type="manga">
<div slot="title" let:title={manga} let:progress>
{pendingUpdate === manga.id ? progress + 1 : progress}{#if !due}
<span class="opaque">/{manga.chapters || '?'}</span>
{/if}
<button
class={`button-square button-action ${pendingUpdate === manga.id ? 'opaque' : ''}`}
style={pendingUpdate === manga.id ? 'pointer-events: none;' : ''}
onclick={() => increment(manga)}
>
+
</button>
{#if due || Math.floor(manga.episodes) < manga.chapters}
[{manga.episodes || '?'}]
{#await volumeCount(manga) then volumes}
{@const volumeProgress = manga.mediaListEntry?.progressVolumes}
{#if volumes !== null && (volumeProgress || 0) < volumes}
<span style="color: lightcoral;">
Vol. {volumeProgress} → {volumes}
</span>
{/if}
{/await}
{/if}
</div>
</CleanGrid>
{:else}
<CleanList media={filteredMedia} type="manga" {lastUpdatedMedia}>
<span slot="information" let:title={manga} let:progress>
<span class="opaque">|</span>
{pendingUpdate === manga.id ? progress + 1 : progress}{#if !due}
<span class="opaque">/{manga.chapters || '?'}</span>
{/if}
<button
class={`button-square button-action ${pendingUpdate === manga.id ? 'opaque' : ''}`}
style={pendingUpdate === manga.id ? 'pointer-events: none;' : ''}
onclick={() => increment(manga)}
>
+
</button>
{#if due || Math.floor(manga.episodes) < manga.chapters}
[{manga.episodes || '?'}]
{#await volumeCount(manga) then volumes}
{@const volumeProgress = manga.mediaListEntry?.progressVolumes}
{#if volumes !== null && (volumeProgress || 0) < volumes}
<span style="color: lightcoral;">
Vol. {volumeProgress} → {volumes}
</span>
{/if}
{/await}
{/if}
</span>
</CleanList>
{/if}
|