diff options
| author | Fuwn <[email protected]> | 2024-01-31 02:20:30 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-01-31 02:20:30 -0800 |
| commit | 735b9d06d4a63cee42b7635a3d806717e55cd762 (patch) | |
| tree | 49c59d41756c31abf6eb3b43805378b4d2bfeaf5 /src/lib | |
| parent | refactor(css): use gap for all gaps (diff) | |
| download | due.moe-735b9d06d4a63cee42b7635a3d806717e55cd762.tar.xz due.moe-735b9d06d4a63cee42b7635a3d806717e55cd762.zip | |
refactor(list): use global identity
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/List/Anime/AnimeListTemplate.svelte | 8 | ||||
| -rw-r--r-- | src/lib/List/Anime/CleanAnimeList.svelte | 10 | ||||
| -rw-r--r-- | src/lib/List/Anime/CompletedAnimeList.svelte | 7 | ||||
| -rw-r--r-- | src/lib/List/Anime/DueAnimeList.svelte | 17 | ||||
| -rw-r--r-- | src/lib/List/Anime/UpcomingAnimeList.svelte | 8 | ||||
| -rw-r--r-- | src/lib/List/Manga/MangaListTemplate.svelte | 18 |
6 files changed, 28 insertions, 40 deletions
diff --git a/src/lib/List/Anime/AnimeListTemplate.svelte b/src/lib/List/Anime/AnimeListTemplate.svelte index 9eab9e33..ca58fb34 100644 --- a/src/lib/List/Anime/AnimeListTemplate.svelte +++ b/src/lib/List/Anime/AnimeListTemplate.svelte @@ -1,7 +1,7 @@ <script lang="ts"> /* eslint svelte/no-at-html-tags: "off" */ - import type { AniListAuthorisation, UserIdentity } from '$lib/AniList/identity'; + import type { AniListAuthorisation } from '$lib/AniList/identity'; import type { Media } from '$lib/AniList/media'; import Error from '$lib/Error/RateLimited.svelte'; import settings from '$stores/settings'; @@ -12,6 +12,7 @@ import { browser } from '$app/environment'; import { onMount } from 'svelte'; import subsPlease from '$stores/subsPlease'; + import identity from '$stores/identity'; export let endTime: number; export let cleanMedia: ( @@ -22,7 +23,6 @@ ) => Media[]; export let animeLists: Promise<Media[]>; export let user: AniListAuthorisation; - export let identity: UserIdentity; export let title: any; export let completed = false; export let plannedOnly = false; @@ -56,7 +56,6 @@ {title} bind:animeLists {user} - {identity} {endTime} bind:lastUpdatedMedia {completed} @@ -69,7 +68,7 @@ <PlaceholderList count={lastListSize} {title} /> {/if} {:then media} - {#if identity.id === -2} + {#if $identity.id === -2} <PlaceholderList count={lastListSize} {title} /> {:else} <CleanAnimeList @@ -77,7 +76,6 @@ {title} bind:animeLists {user} - {identity} {endTime} bind:lastUpdatedMedia {completed} diff --git a/src/lib/List/Anime/CleanAnimeList.svelte b/src/lib/List/Anime/CleanAnimeList.svelte index dd135566..271c8991 100644 --- a/src/lib/List/Anime/CleanAnimeList.svelte +++ b/src/lib/List/Anime/CleanAnimeList.svelte @@ -5,7 +5,7 @@ import type { Media } from '$lib/AniList/media'; import { cleanCache, incrementMediaProgress } from '$lib/Media/Anime/cache'; import { totalEpisodes } from '$lib/Media/Anime/episodes'; - import type { AniListAuthorisation, UserIdentity } from '$lib/AniList/identity'; + import type { AniListAuthorisation } from '$lib/AniList/identity'; import ListTitle from '../ListTitle.svelte'; import MediaTitle from '../MediaTitleDisplay.svelte'; import { outboundLink } from '$lib/Media/links'; @@ -22,12 +22,12 @@ import tooltip from '$lib/Tooltip/tooltip'; import AiringTime from '$lib/Media/Anime/Airing/AiringTime.svelte'; import { browser } from '$app/environment'; + import identity from '$stores/identity'; export let media: Media[]; export let title: any; export let animeLists: Promise<Media[]>; export let user: AniListAuthorisation; - export let identity: UserIdentity; export let endTime: number; export let lastUpdatedMedia: number; export let completed = false; @@ -70,7 +70,7 @@ <ListTitle time={endTime / 1000} count={media.length} {title} /> {#if media.length === 0} - No anime to display. <button on:click={() => (animeLists = cleanCache(user, identity))}> + No anime to display. <button on:click={() => (animeLists = cleanCache(user, $identity))}> Force refresh </button> {/if} @@ -111,7 +111,7 @@ if (mediaListEntry) mediaListEntry.progress = progress + 1; previousAnimeList = media; - animeLists = cleanCache(user, identity); + animeLists = cleanCache(user, $identity); pendingUpdate = null; }); } @@ -198,7 +198,7 @@ if (mediaListEntry) mediaListEntry.progress = progress + 1; previousAnimeList = media; - animeLists = cleanCache(user, identity); + animeLists = cleanCache(user, $identity); pendingUpdate = null; }); } diff --git a/src/lib/List/Anime/CompletedAnimeList.svelte b/src/lib/List/Anime/CompletedAnimeList.svelte index 2d317aeb..ef1b103a 100644 --- a/src/lib/List/Anime/CompletedAnimeList.svelte +++ b/src/lib/List/Anime/CompletedAnimeList.svelte @@ -1,6 +1,6 @@ <script lang="ts"> import { mediaListCollection, Type, type Media } from '$lib/AniList/media'; - import type { UserIdentity, AniListAuthorisation } from '$lib/AniList/identity'; + import type { AniListAuthorisation } from '$lib/AniList/identity'; import { onMount } from 'svelte'; import anime from '$stores/anime'; import lastPruneTimes from '$stores/lastPruneTimes'; @@ -8,9 +8,9 @@ import AnimeList from './AnimeListTemplate.svelte'; import { getNotificationsContext } from 'svelte-notifications'; import locale from '$stores/locale'; + import identity from '$stores/identity'; export let user: AniListAuthorisation; - export let identity: UserIdentity; const { addNotification } = getNotificationsContext(); let animeLists: Promise<Media[]>; @@ -19,7 +19,7 @@ onMount(async () => { startTime = performance.now(); - animeLists = mediaListCollection(user, identity, Type.Anime, $anime, $lastPruneTimes.anime, { + animeLists = mediaListCollection(user, $identity, Type.Anime, $anime, $lastPruneTimes.anime, { addNotification }); }); @@ -54,7 +54,6 @@ {cleanMedia} bind:animeLists {user} - {identity} title={$locale().lists.completed.anime} completed /> diff --git a/src/lib/List/Anime/DueAnimeList.svelte b/src/lib/List/Anime/DueAnimeList.svelte index 83b2890b..ce946ff4 100644 --- a/src/lib/List/Anime/DueAnimeList.svelte +++ b/src/lib/List/Anime/DueAnimeList.svelte @@ -1,6 +1,6 @@ <script lang="ts"> import { mediaListCollection, Type, type Media } from '$lib/AniList/media'; - import type { UserIdentity, AniListAuthorisation } from '$lib/AniList/identity'; + import type { AniListAuthorisation } from '$lib/AniList/identity'; import { onDestroy, onMount } from 'svelte'; import anime from '$stores/anime'; import settings from '$stores/settings'; @@ -10,9 +10,9 @@ import { injectAiringTime } from '$lib/Media/Anime/Airing/Subtitled/match'; import { getNotificationsContext } from 'svelte-notifications'; import locale from '$stores/locale'; + import identity from '$stores/identity'; export let user: AniListAuthorisation; - export let identity: UserIdentity; const { addNotification } = getNotificationsContext(); let animeLists: Promise<Media[]>; @@ -22,7 +22,7 @@ const keyCacher = setInterval(() => { startTime = performance.now(); endTime = -1; - animeLists = mediaListCollection(user, identity, Type.Anime, $anime, $lastPruneTimes.anime, { + animeLists = mediaListCollection(user, $identity, Type.Anime, $anime, $lastPruneTimes.anime, { forcePrune: true, addNotification }); @@ -30,7 +30,7 @@ onMount(async () => { startTime = performance.now(); - animeLists = mediaListCollection(user, identity, Type.Anime, $anime, $lastPruneTimes.anime, { + animeLists = mediaListCollection(user, $identity, Type.Anime, $anime, $lastPruneTimes.anime, { addNotification }); }); @@ -91,11 +91,4 @@ }; </script> -<AnimeList - {endTime} - {cleanMedia} - bind:animeLists - {user} - {identity} - title={$locale().lists.due.episodes} -/> +<AnimeList {endTime} {cleanMedia} bind:animeLists {user} title={$locale().lists.due.episodes} /> diff --git a/src/lib/List/Anime/UpcomingAnimeList.svelte b/src/lib/List/Anime/UpcomingAnimeList.svelte index 755f1b40..f274ee28 100644 --- a/src/lib/List/Anime/UpcomingAnimeList.svelte +++ b/src/lib/List/Anime/UpcomingAnimeList.svelte @@ -1,6 +1,6 @@ <script lang="ts"> import { mediaListCollection, Type, type Media } from '$lib/AniList/media'; - import type { UserIdentity, AniListAuthorisation } from '$lib/AniList/identity'; + import type { AniListAuthorisation } from '$lib/AniList/identity'; import { onMount } from 'svelte'; import anime from '$stores/anime'; import lastPruneTimes from '$stores/lastPruneTimes'; @@ -9,9 +9,9 @@ import type { SubsPlease } from '$lib/Media/Anime/Airing/Subtitled/subsPlease'; import { getNotificationsContext } from 'svelte-notifications'; import locale from '$stores/locale'; + import identity from '$stores/identity'; export let user: AniListAuthorisation; - export let identity: UserIdentity; const { addNotification } = getNotificationsContext(); let animeLists: Promise<Media[]>; @@ -20,7 +20,7 @@ onMount(async () => { startTime = performance.now(); - animeLists = mediaListCollection(user, identity, Type.Anime, $anime, $lastPruneTimes.anime, { + animeLists = mediaListCollection(user, $identity, Type.Anime, $anime, $lastPruneTimes.anime, { addNotification, notificationType: 'Upcoming Episodes' }); @@ -81,7 +81,6 @@ {cleanMedia} bind:animeLists {user} - {identity} title={$locale().lists.upcoming.episodes} upcoming /> @@ -94,7 +93,6 @@ {cleanMedia} bind:animeLists {user} - {identity} title={$locale().lists.upcoming.notYetReleased} notYetReleased plannedOnly diff --git a/src/lib/List/Manga/MangaListTemplate.svelte b/src/lib/List/Manga/MangaListTemplate.svelte index 2e625569..d1bc2633 100644 --- a/src/lib/List/Manga/MangaListTemplate.svelte +++ b/src/lib/List/Manga/MangaListTemplate.svelte @@ -1,6 +1,6 @@ <script lang="ts"> import { mediaListCollection, Type, type Media } from '$lib/AniList/media'; - import type { UserIdentity, AniListAuthorisation } from '$lib/AniList/identity'; + import type { AniListAuthorisation } from '$lib/AniList/identity'; import { onDestroy, onMount } from 'svelte'; import { chapterCount } from '$lib/Media/Manga/chapters'; import { pruneAllManga } from '$lib/Media/Manga/cache'; @@ -18,14 +18,14 @@ import Skeleton from '$lib/Loading/Skeleton.svelte'; import locale from '$stores/locale'; import { browser } from '$app/environment'; + import identity from '$stores/identity'; export let user: AniListAuthorisation; - export let identity: UserIdentity; export let displayUnresolved: boolean; export let due: boolean; const { addNotification } = getNotificationsContext(); - const authorised = authorisedJson.includes(identity.id); + const authorised = authorisedJson.includes($identity.id); let mangaLists: Promise<Media[]>; let startTime: number; let endTime: number; @@ -40,7 +40,7 @@ const keyCacher = setInterval(() => { startTime = performance.now(); endTime = -1; - mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $lastPruneTimes.manga, { + mangaLists = mediaListCollection(user, $identity, Type.Manga, $manga, $lastPruneTimes.manga, { addNotification }); }, $settings.cacheMinutes * 1000 * 60); @@ -53,7 +53,7 @@ } startTime = performance.now(); - mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $lastPruneTimes.manga, { + mangaLists = mediaListCollection(user, $identity, Type.Manga, $manga, $lastPruneTimes.manga, { addNotification }); }); @@ -119,14 +119,14 @@ if (!due) return new Promise((resolve) => resolve(m.chapters)) as Promise<number | null>; - if (c !== undefined) return chapterCount(identity, m, $settings.calculateGuessingDisabled); + if (c !== undefined) return chapterCount($identity, m, $settings.calculateGuessingDisabled); else { // A = On 1 second interval, // B = a maximum of 5 requests per second are allowed. // C = chapterCount makes 3 requests per call. // F = A / (B / C) = 0.6 seconds return new Promise((resolve) => setTimeout(resolve, 600)).then(() => - chapterCount(identity, m, $settings.calculateGuessingDisabled) + chapterCount($identity, m, $settings.calculateGuessingDisabled) ); } }) @@ -188,7 +188,7 @@ if (foundEntry && foundEntry.mediaListEntry) foundEntry.mediaListEntry.progress = (progress || 0) + 1; - mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $lastPruneTimes.manga, { + mangaLists = mediaListCollection(user, $identity, Type.Manga, $manga, $lastPruneTimes.manga, { forcePrune: true }); pendingUpdate = null; @@ -200,7 +200,7 @@ endTime = -1; pruneAllManga().then(() => { - mangaLists = mediaListCollection(user, identity, Type.Manga, $manga, $lastPruneTimes.manga, { + mangaLists = mediaListCollection(user, $identity, Type.Manga, $manga, $lastPruneTimes.manga, { forcePrune: true }); }); |