diff options
Diffstat (limited to 'src/lib/Media/Anime')
| -rw-r--r-- | src/lib/Media/Anime/cache.ts | 12 |
1 files changed, 12 insertions, 0 deletions
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); +}; |