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(
(value: AniListGetSingleAnime) => {
// 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
// delete value.data.MediaList.media.tags
/* 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
delete value.data.MediaList.media.tags */
aniListAnime.update((newValue) => {
newValue = value;
return newValue;
@ -397,6 +397,16 @@
submitSuccess.set(true);
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>
<form on:submit|preventDefault={handleSubmit} class="container pt-3 pb-10">
@ -427,7 +437,7 @@
type="number"
name="episodes"
min="0"
max={currentAniListAnime.data.MediaList.media.episodes}
max={max}
id="episodes"
class="border {currentAniListAnime.data.MediaList
.progress < 0 ||
@ -448,9 +458,11 @@
.nextAiringEpisode.episode - 1
: currentAniListAnime.data.MediaList.media.episodes}
</div>
{#if currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode !== 0}
<div>
of {currentAniListAnime.data.MediaList.media.episodes}
</div>
{/if}
</div>
<div>