diff options
Diffstat (limited to 'src/lib/List/Manga/MangaListTemplate.svelte')
| -rw-r--r-- | src/lib/List/Manga/MangaListTemplate.svelte | 127 |
1 files changed, 75 insertions, 52 deletions
diff --git a/src/lib/List/Manga/MangaListTemplate.svelte b/src/lib/List/Manga/MangaListTemplate.svelte index 2cdeb094..5409a3d9 100644 --- a/src/lib/List/Manga/MangaListTemplate.svelte +++ b/src/lib/List/Manga/MangaListTemplate.svelte @@ -11,12 +11,14 @@ import ListTitle from '../ListTitle.svelte'; import Error from '$lib/Error.svelte'; import CleanMangaList from './CleanMangaList.svelte'; + import authorisedJson from '$lib/authorised.json'; export let user: AniListAuthorisation; export let identity: UserIdentity; export let displayUnresolved: boolean; export let due: boolean; + const authorised = authorisedJson.includes(identity.id); let mangaLists: Promise<Media[]>; let startTime: number; let endTime: number; @@ -45,22 +47,25 @@ if (manga === undefined) return []; - 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)); - // })(); - // } - // } + if (!authorised && (await database.chapters.toArray()).length <= 0 && !force) return []; + + if (authorised) { + 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) => @@ -173,17 +178,19 @@ </script> {#await mangaLists} - <ListTitle count={0} time={endTime / 1000}> - <a - href={'#'} - title="Force a full refresh" - on:click={() => { - cleanCache(); - - forceFlag = true; - }}>Refresh</a - > - </ListTitle> + {#if !authorised} + <ListTitle count={0} time={endTime / 1000}> + <a + href={'#'} + title="Force a full refresh" + on:click={() => { + cleanCache(); + + forceFlag = true; + }}>Refresh</a + > + </ListTitle> + {/if} {#if previousMangaList} <CleanMangaList @@ -191,28 +198,34 @@ {cleanCache} {lastUpdatedMedia} {updateMedia} + {endTime} {pendingUpdate} {due} {rateLimited} + {authorised} /> {:else} - <!-- <ListTitle /> --> + {#if authorised} + <ListTitle /> + {/if} <ul><li>Loading {progress.toFixed(0)}% ...</li></ul> {/if} {:then media} {#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 !authorised} + <ListTitle count={0} time={endTime / 1000}> + <a + href={'#'} + title="Force a full refresh" + on:click={() => { + cleanCache(); + + forceFlag = true; + }}>Refresh</a + > + </ListTitle> + {/if} {#if previousMangaList} <CleanMangaList @@ -220,39 +233,49 @@ {cleanCache} {lastUpdatedMedia} {updateMedia} + {endTime} {pendingUpdate} {due} {rateLimited} + {authorised} /> {:else} - <!-- <ListTitle /> --> + {#if authorised} + <ListTitle /> + {/if} <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> + {#if !authorised} + <ListTitle count={cleanedMedia.length} time={endTime / 1000}> + <a + href={'#'} + title="Force a full refresh" + on:click={() => { + cleanCache(); + + forceFlag = true; + }}>Refresh</a + > + </ListTitle> + {/if} <CleanMangaList media={cleanedMedia} {cleanCache} {lastUpdatedMedia} {updateMedia} + {endTime} {pendingUpdate} {due} {rateLimited} + {authorised} /> {:catch} - <!-- <ListTitle count={-1337} time={0} /> --> + {#if authorised} + <ListTitle count={-1337} time={0} /> + {/if} <Error /> {/await} |