aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Media/Anime/cache.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Media/Anime/cache.ts')
-rw-r--r--src/lib/Media/Anime/cache.ts65
1 files changed, 39 insertions, 26 deletions
diff --git a/src/lib/Media/Anime/cache.ts b/src/lib/Media/Anime/cache.ts
index 9aabb2ab..e988f255 100644
--- a/src/lib/Media/Anime/cache.ts
+++ b/src/lib/Media/Anime/cache.ts
@@ -1,31 +1,44 @@
-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';
+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 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
+ 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);
+ 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);
};