aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Media/Anime/cache.ts
blob: 1b91e46e3fde30e3d652c7c991e8ac6ea5c29c8d (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);
};