From 59c404317de10d04119089ad4eddfbc1a49740b4 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 25 Sep 2023 21:33:11 -0700 Subject: feat(manga): replace list titles --- src/lib/List/Due/MangaList.svelte | 19 +++++++++++-------- src/lib/List/Due/MangaTitle.svelte | 8 ++++++++ src/lib/Media/manga.ts | 9 +++++++++ src/routes/+page.svelte | 4 +++- src/routes/settings/+page.svelte | 10 ++-------- 5 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 src/lib/List/Due/MangaTitle.svelte (limited to 'src') diff --git a/src/lib/List/Due/MangaList.svelte b/src/lib/List/Due/MangaList.svelte index 4b207351..0f3e511b 100644 --- a/src/lib/List/Due/MangaList.svelte +++ b/src/lib/List/Due/MangaList.svelte @@ -2,11 +2,12 @@ import { mediaListCollection, Type, type Media } from '$lib/AniList/media'; import type { UserIdentity, AniListAuthorisation } from '$lib/AniList/identity'; import { onDestroy, onMount } from 'svelte'; - import { chapterCount } from '$lib/Media/manga'; + import { chapterCount, pruneAllManga } from '$lib/Media/manga'; import manga from '../../../stores/manga'; import { chapterDatabase } from '$lib/Media/chapters'; import settings from '../../../stores/settings'; import lastPruneTimes from '../../../stores/lastPruneTimes'; + import MangaTitle from './MangaTitle.svelte'; export let user: AniListAuthorisation; export let identity: UserIdentity; @@ -112,7 +113,9 @@ }); }; - const cleanCache = () => { + const cleanCache = async () => { + await pruneAllManga(); + mangaLists = mediaListCollection( user, identity, @@ -125,19 +128,18 @@ {#await mangaLists} - Manga & Light Novels [...] ...s + {:then media} {#await cleanMedia(media, displayUnresolved)} - Manga & Light Novels [...] ...s +
  • Loading ...
{:then cleanedMedia} - - Manga & Light Novels [{cleanedMedia.length}] - {endTime / 1000}s - + + Force + {#if cleanedMedia.length === 0}
    @@ -160,6 +162,7 @@
{:catch} Manga & Light Novels [?] 0s +
  • diff --git a/src/lib/List/Due/MangaTitle.svelte b/src/lib/List/Due/MangaTitle.svelte new file mode 100644 index 00000000..aee467dd --- /dev/null +++ b/src/lib/List/Due/MangaTitle.svelte @@ -0,0 +1,8 @@ + + +Manga & Light Novels [{count}] {time}s diff --git a/src/lib/Media/manga.ts b/src/lib/Media/manga.ts index c2bbf5db..9d0e08a6 100644 --- a/src/lib/Media/manga.ts +++ b/src/lib/Media/manga.ts @@ -1,7 +1,16 @@ import { recentMediaActivities, type Media } from '$lib/AniList/media'; +import manga from '../../stores/manga'; import type { UserIdentity } from '../AniList/identity'; import { chapterDatabase } from './chapters'; +export const pruneAllManga = async () => { + const all = await chapterDatabase.chapters.toArray(); + const ids = all.map((m) => m.id); + + manga.set(''); + await chapterDatabase.chapters.bulkDelete(ids); +}; + export const chapterCount = async ( identity: UserIdentity, manga: Media, diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ee021e1d..72422fe0 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -8,6 +8,7 @@ import settings from '../stores/settings'; import WatchingAnimeList from '$lib/List/WatchingAnimeList.svelte'; import { lastActivityDate } from '$lib/AniList/activity'; + import MangaTitle from '$lib/List/Due/MangaTitle.svelte'; export let data; @@ -116,7 +117,8 @@ displayUnresolved={$settings.displayUnresolved} /> {:else} - Manga & Light Novels [...] ...s + +
    • Loading ...
    {/if} diff --git a/src/routes/settings/+page.svelte b/src/routes/settings/+page.svelte index 2fe6b466..6cc336e6 100644 --- a/src/routes/settings/+page.svelte +++ b/src/routes/settings/+page.svelte @@ -7,6 +7,7 @@ import settings from '../../stores/settings'; import SettingToggle from '$lib/Settings/SettingToggle.svelte'; import SettingHint from '$lib/Settings/SettingHint.svelte'; + import { pruneAllManga } from '$lib/Media/manga'; export let data; @@ -18,13 +19,6 @@ anime.set(''); await chapterDatabase.chapters.bulkDelete(ids); }; - const pruneAll = async () => { - const all = await chapterDatabase.chapters.toArray(); - const ids = all.map((m) => m.id); - - manga.set(''); - await chapterDatabase.chapters.bulkDelete(ids); - }; {#if data.user === undefined} @@ -129,7 +123,7 @@

    - Re-cache ALL manga + Re-cache ALL manga Force a re-cache of all cached manga chapter counts

    -- cgit v1.2.3