fixed bug in episode input when 0

This commit is contained in:
John O'Keefe 2024-12-06 16:30:53 -05:00
parent 3edfed6272
commit 3ab77ea8d3

View File

@ -193,9 +193,9 @@
}; };
await AniListUpdateEntry(body).then( await AniListUpdateEntry(body).then(
(value: AniListGetSingleAnime) => { (value: AniListGetSingleAnime) => {
// in future when you inevitably add tags to typescript, until Anilist fixes the api bug /* TODO in future when you inevitably add tags to typescript, until Anilist fixes the api bug
// where tags break the SaveMediaListEntry return, you'll want to use this delete line where tags break the SaveMediaListEntry return, you'll want to use this delete line
// delete value.data.MediaList.media.tags delete value.data.MediaList.media.tags */
aniListAnime.update((newValue) => { aniListAnime.update((newValue) => {
newValue = value; newValue = value;
return newValue; return newValue;
@ -397,6 +397,16 @@
submitSuccess.set(true); submitSuccess.set(true);
setTimeout(() => submitSuccess.set(false), 2000); setTimeout(() => submitSuccess.set(false), 2000);
}; };
let max = 999
if (currentAniListAnime.data.MediaList.media.episodes !== 0) {
max = currentAniListAnime.data.MediaList.media.episodes
}
if (currentAniListAnime.data.MediaList.media.episodes === 0 &&
currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode !== 0) {
max = currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode - 1
}
</script> </script>
<form on:submit|preventDefault={handleSubmit} class="container pt-3 pb-10"> <form on:submit|preventDefault={handleSubmit} class="container pt-3 pb-10">
@ -427,7 +437,7 @@
type="number" type="number"
name="episodes" name="episodes"
min="0" min="0"
max={currentAniListAnime.data.MediaList.media.episodes} max={max}
id="episodes" id="episodes"
class="border {currentAniListAnime.data.MediaList class="border {currentAniListAnime.data.MediaList
.progress < 0 || .progress < 0 ||
@ -448,9 +458,11 @@
.nextAiringEpisode.episode - 1 .nextAiringEpisode.episode - 1
: currentAniListAnime.data.MediaList.media.episodes} : currentAniListAnime.data.MediaList.media.episodes}
</div> </div>
{#if currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode !== 0}
<div> <div>
of {currentAniListAnime.data.MediaList.media.episodes} of {currentAniListAnime.data.MediaList.media.episodes}
</div> </div>
{/if}
</div> </div>
<div> <div>