From c81e430c62459255fe02a75d3794860acd02c3b8 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 10 Sep 2023 02:15:56 -0700 Subject: refactor(anime): generalise update media --- src/lib/List/WatchingAnimeList.svelte | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/lib/List/WatchingAnimeList.svelte') diff --git a/src/lib/List/WatchingAnimeList.svelte b/src/lib/List/WatchingAnimeList.svelte index e76b1ef0..2c298488 100644 --- a/src/lib/List/WatchingAnimeList.svelte +++ b/src/lib/List/WatchingAnimeList.svelte @@ -7,7 +7,7 @@ import anime from '../../stores/anime'; import lastPruneTimes from '../../stores/lastPruneTimes'; import settings from '../../stores/settings'; - import { cleanCache, totalEpisodes } from '$lib/anime'; + import { cleanCache, totalEpisodes, updateMedia } from '$lib/anime'; export let user: AniListAuthorisation; export let identity: UserIdentity; @@ -59,12 +59,6 @@ return finalMedia; }; - - const updateMedia = async (id: number, progress: number | undefined) => { - fetch(`/anilist/increment?id=${id}&progress=${(progress || 0) + 1}`).then(() => { - animeLists = cleanCache(user, identity); - }); - }; {#await animeLists} @@ -105,7 +99,15 @@ | {anime.mediaListEntry?.progress || 0}{@html totalEpisodes(anime)} - updateMedia(anime.id, anime.mediaListEntry?.progress)}>+ + + updateMedia( + anime.id, + anime.mediaListEntry?.progress, + () => (animeLists = cleanCache(user, identity)) + )}>+ {/each} -- cgit v1.2.3