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 +++++++++ 3 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 src/lib/List/Due/MangaTitle.svelte (limited to 'src/lib') 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, -- cgit v1.2.3