diff options
| author | Fuwn <[email protected]> | 2023-12-22 08:12:07 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2023-12-22 08:15:08 -0800 |
| commit | 2c78e5013fe2c9e1faff79e6067a18c0d82c14ea (patch) | |
| tree | 8d38f86ce110e1d160dc7cb2d8c5b2008f2f7d6d /src/lib | |
| parent | feat(wrapped): genres and tags (diff) | |
| download | due.moe-2c78e5013fe2c9e1faff79e6067a18c0d82c14ea.tar.xz due.moe-2c78e5013fe2c9e1faff79e6067a18c0d82c14ea.zip | |
feat(manga): manual refresh
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/List/Manga/CleanMangaList.svelte | 8 | ||||
| -rw-r--r-- | src/lib/List/Manga/MangaListTemplate.svelte | 84 |
2 files changed, 64 insertions, 28 deletions
diff --git a/src/lib/List/Manga/CleanMangaList.svelte b/src/lib/List/Manga/CleanMangaList.svelte index 0100db72..03bde311 100644 --- a/src/lib/List/Manga/CleanMangaList.svelte +++ b/src/lib/List/Manga/CleanMangaList.svelte @@ -4,12 +4,12 @@ import { volumeCount } from '$lib/Media/Manga/volumes'; import { outboundLink } from '$lib/Media/links'; import settings from '../../../stores/settings'; - import ListTitle from '../ListTitle.svelte'; + // import ListTitle from '../ListTitle.svelte'; import MediaTitle from '../MediaTitleDisplay.svelte'; export let media: Media[]; export let cleanCache: () => void; - export let endTime: number; + // export let endTime: number; export let lastUpdatedMedia: number; export let updateMedia: ( id: number, @@ -21,10 +21,6 @@ export let rateLimited: boolean; </script> -<ListTitle count={media.length} time={endTime / 1000}> - <a href={'#'} title="Force a full refresh" on:click={cleanCache}>Refresh</a> -</ListTitle> - {#if rateLimited} <Error /> {/if} diff --git a/src/lib/List/Manga/MangaListTemplate.svelte b/src/lib/List/Manga/MangaListTemplate.svelte index f30cb520..2f05647d 100644 --- a/src/lib/List/Manga/MangaListTemplate.svelte +++ b/src/lib/List/Manga/MangaListTemplate.svelte @@ -25,6 +25,7 @@ let pendingUpdate: number | null = null; let progress = 0; let rateLimited = false; + let forceFlag = false; const keyCacher = setInterval(() => { startTime = performance.now(); @@ -39,25 +40,27 @@ onDestroy(() => clearInterval(keyCacher)); - const cleanMedia = async (manga: Media[], displayUnresolved: boolean) => { + const cleanMedia = async (manga: Media[], displayUnresolved: boolean, force: boolean) => { progress = 0; if (manga === undefined) return []; - if ($lastPruneTimes.chapters === 1) lastPruneTimes.setKey('chapters', new Date().getTime()); - else { - const currentDate = new Date(); - - if ( - (currentDate.getTime() - $lastPruneTimes.chapters) / 1000 / 60 > - Math.max($settings.cacheMangaMinutes, 5) - ) { - lastPruneTimes.setKey('chapters', currentDate.getTime()); - (async () => { - await database.chapters.bulkDelete((await database.chapters.toArray()).map((m) => m.id)); - })(); - } - } + if ((await database.chapters.toArray()).length <= 0 && !force) return []; + + // if ($lastPruneTimes.chapters === 1) lastPruneTimes.setKey('chapters', new Date().getTime()); + // else { + // const currentDate = new Date(); + + // if ( + // (currentDate.getTime() - $lastPruneTimes.chapters) / 1000 / 60 > + // Math.max($settings.cacheMangaMinutes, 5) + // ) { + // lastPruneTimes.setKey('chapters', currentDate.getTime()); + // (async () => { + // await database.chapters.bulkDelete((await database.chapters.toArray()).map((m) => m.id)); + // })(); + // } + // } const releasingMedia = manga.filter( (media: Media) => @@ -169,12 +172,27 @@ }; </script> +<!-- <ListTitle count={media.length} time={endTime / 1000}> + <a href={'#'} title="Force a full refresh" on:click={cleanCache}>Refresh</a> +</ListTitle> --> + {#await mangaLists} + <ListTitle count={0} time={endTime / 1000}> + <a + href={'#'} + title="Force a full refresh" + on:click={() => { + cleanCache(); + + forceFlag = true; + }}>Refresh</a + > + </ListTitle> + {#if previousMangaList} <CleanMangaList media={previousMangaList} {cleanCache} - {endTime} {lastUpdatedMedia} {updateMedia} {pendingUpdate} @@ -182,17 +200,28 @@ {rateLimited} /> {:else} - <ListTitle /> + <!-- <ListTitle /> --> <ul><li>Loading {progress.toFixed(0)}% ...</li></ul> {/if} {:then media} - {#await cleanMedia(media, displayUnresolved)} + {#await cleanMedia(media, displayUnresolved, forceFlag)} + <ListTitle count={0} time={endTime / 1000}> + <a + href={'#'} + title="Force a full refresh" + on:click={() => { + cleanCache(); + + forceFlag = true; + }}>Refresh</a + > + </ListTitle> + {#if previousMangaList} <CleanMangaList media={previousMangaList} {cleanCache} - {endTime} {lastUpdatedMedia} {updateMedia} {pendingUpdate} @@ -200,15 +229,26 @@ {rateLimited} /> {:else} - <ListTitle /> + <!-- <ListTitle /> --> <ul><li>Loading {progress.toFixed(0)}% ...</li></ul> {/if} {:then cleanedMedia} + <ListTitle count={cleanedMedia.length} time={endTime / 1000}> + <a + href={'#'} + title="Force a full refresh" + on:click={() => { + cleanCache(); + + forceFlag = true; + }}>Refresh</a + > + </ListTitle> + <CleanMangaList media={cleanedMedia} {cleanCache} - {endTime} {lastUpdatedMedia} {updateMedia} {pendingUpdate} @@ -216,7 +256,7 @@ {rateLimited} /> {:catch} - <ListTitle count={-1337} time={0} /> + <!-- <ListTitle count={-1337} time={0} /> --> <Error /> {/await} |