1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import { get } from 'svelte/store';
import anime from '$stores/anime';
import { mediaListCollection, Type } from '../../Data/AniList/media';
import lastPruneTimes from '$stores/lastPruneTimes';
import type { AniListAuthorisation, UserIdentity } from '../../Data/AniList/identity';
export const cleanCache = (user: AniListAuthorisation, identity: UserIdentity) =>
mediaListCollection(user, identity, Type.Anime, get(anime), get(lastPruneTimes).anime, {
forcePrune: true
});
export const incrementMediaProgress = (
id: number,
progress: number | undefined,
user: AniListAuthorisation,
callback: () => void
) => {
fetch('https://graphql.anilist.co', {
method: 'POST',
headers: {
Authorization: `${user.tokenType} ${user.accessToken}`,
'Content-Type': 'application/json',
Accept: 'application/json'
},
body: JSON.stringify({
query: `mutation { SaveMediaListEntry(mediaId: ${id}, progress: ${
(progress || 0) + 1
}) { id } }`
})
}).then(callback);
};
|