From 10f98276c252eb752de261bb191ccd6d0c7f893a Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 17 Dec 2023 04:38:47 -0800 Subject: refactor(anime): move cache --- src/lib/Media/Anime/cache.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/lib/Media/Anime/cache.ts (limited to 'src/lib/Media/Anime/cache.ts') diff --git a/src/lib/Media/Anime/cache.ts b/src/lib/Media/Anime/cache.ts new file mode 100644 index 00000000..c423a419 --- /dev/null +++ b/src/lib/Media/Anime/cache.ts @@ -0,0 +1,12 @@ +import { get } from 'svelte/store'; +import anime from '../../../stores/anime'; +import { mediaListCollection, Type } from '../../AniList/media'; +import lastPruneTimes from '../../../stores/lastPruneTimes'; +import type { AniListAuthorisation, UserIdentity } from '../../AniList/identity'; + +export const cleanCache = (user: AniListAuthorisation, identity: UserIdentity) => + mediaListCollection(user, identity, Type.Anime, get(anime), get(lastPruneTimes).anime, true); + +export const updateMedia = (id: number, progress: number | undefined, callback: () => void) => { + fetch(`/api/anilist/increment?id=${id}&progress=${(progress || 0) + 1}`).then(callback); +}; -- cgit v1.2.3