aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Media/Anime/cache.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2023-12-17 04:38:47 -0800
committerFuwn <[email protected]>2023-12-17 04:38:47 -0800
commit10f98276c252eb752de261bb191ccd6d0c7f893a (patch)
tree29e491a0b6c74b5bf9368c46494f9dc8de8a28b7 /src/lib/Media/Anime/cache.ts
parentrefactor(anime): move episodes (diff)
downloaddue.moe-10f98276c252eb752de261bb191ccd6d0c7f893a.tar.xz
due.moe-10f98276c252eb752de261bb191ccd6d0c7f893a.zip
refactor(anime): move cache
Diffstat (limited to 'src/lib/Media/Anime/cache.ts')
-rw-r--r--src/lib/Media/Anime/cache.ts12
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);
+};