diff options
| author | Fuwn <[email protected]> | 2024-01-12 20:28:27 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-12 20:28:40 -0800 |
| commit | 417e5506525e9f1b0421c288034862655519b1fa (patch) | |
| tree | b0d34e8464cfdbbbd324305407f7ed74f6f09278 | |
| parent | feat(manga): smaller progress update (diff) | |
| download | due.moe-417e5506525e9f1b0421c288034862655519b1fa.tar.xz due.moe-417e5506525e9f1b0421c288034862655519b1fa.zip | |
feat(manga): refresh notification
| -rw-r--r-- | src/lib/List/Manga/MangaListTemplate.svelte | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/lib/List/Manga/MangaListTemplate.svelte b/src/lib/List/Manga/MangaListTemplate.svelte index 37023509..52cfbc82 100644 --- a/src/lib/List/Manga/MangaListTemplate.svelte +++ b/src/lib/List/Manga/MangaListTemplate.svelte @@ -14,6 +14,7 @@ import authorisedJson from '$lib/authorised.json'; import { incrementMediaProgress } from '$lib/Media/Anime/cache'; import { getNotificationsContext } from 'svelte-notifications'; + import { options } from '$lib/Notification/options'; export let user: AniListAuthorisation; export let identity: UserIdentity; @@ -57,13 +58,21 @@ if (!authorised && (await database.chapters.toArray()).length <= 0 && !force) return []; if (authorised) { - if ($lastPruneTimes.chapters === 1) lastPruneTimes.setKey('chapters', new Date().getTime()); - else { + let refreshing = false; + + if ($lastPruneTimes.chapters === 1) { + refreshing = true; + + lastPruneTimes.setKey('chapters', new Date().getTime()); + } else { const currentDate = new Date(); + if ( (currentDate.getTime() - $lastPruneTimes.chapters) / 1000 / 60 > Math.max($settings.cacheMangaMinutes, 5) ) { + refreshing = true; + lastPruneTimes.setKey('chapters', currentDate.getTime()); (async () => { await database.chapters.bulkDelete( @@ -72,6 +81,15 @@ })(); } } + + if (refreshing) { + addNotification( + options({ + heading: 'Manga', + description: 'Re-freshing manga data ...' + }) + ); + } } const releasingMedia = manga.filter( |