From 3f0754c899f84648f05b3a8fbf0a6e66d9ec3bdf Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 10 Sep 2023 02:09:38 -0700 Subject: refactor(anime): generalise clean cache --- src/lib/anime.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/lib/anime.ts') diff --git a/src/lib/anime.ts b/src/lib/anime.ts index 8547882f..2ebdf25e 100644 --- a/src/lib/anime.ts +++ b/src/lib/anime.ts @@ -1,4 +1,19 @@ -import type { Media } from './AniList/media'; +import { get } from 'svelte/store'; +import anime from '../stores/anime'; +import { mediaListCollection, type Media, Type } from './AniList/media'; +import lastPruneTimes from '../stores/lastPruneTimes'; +import type { AniListAuthorisation, UserIdentity } from './AniList/identity'; + +export const cleanCache = (user: AniListAuthorisation, identity: UserIdentity) => { + return mediaListCollection( + user, + identity, + Type.Anime, + get(anime), + get(lastPruneTimes).anime, + true + ); +}; export const totalEpisodes = (anime: Media) => { return anime.episodes === null ? '' : `/${anime.episodes}`; -- cgit v1.2.3