aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Media/Anime/cache.ts
blob: 60164f858cde782f74d6c9b4ac7e257f1c4e13c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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, {
		forcePrune: true
	});

export const updateMedia = (id: number, progress: number | undefined, callback: () => void) => {
	fetch(`/api/anilist/increment?id=${id}&progress=${(progress || 0) + 1}`).then(callback);
};