diff --git a/CHANGELOG.md b/CHANGELOG.md index b18da4c6..7184eed4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ These changes are awaiting release: ## Changed - HTTP Requests: Replace `axios` with `Fetch`. +- Show `Airs On` date for episodes that have yet to air (thanks [@KarpachMarko]!). ## Fixed @@ -1858,3 +1859,4 @@ Welcome to Watcharr :popcorn:, hope it is enjoyed and improves anyone's experien [@4qu4r1um]: https://github.com/4qu4r1um [@goestav]: https://github.com/goestav [@tonghuaroot]: https://github.com/tonghuaroot +[@KarpachMarko]: https://github.com/KarpachMarko diff --git a/src/lib/season/SeasonsListEpisode.svelte b/src/lib/season/SeasonsListEpisode.svelte index ff956626..da4c972c 100644 --- a/src/lib/season/SeasonsListEpisode.svelte +++ b/src/lib/season/SeasonsListEpisode.svelte @@ -11,6 +11,7 @@ import { store } from "@/store.svelte"; import { removeWatchedEpisode, updateWatchedEpisode } from "./api"; import { onMount } from "svelte"; + import { toRelativeDate } from "../util/helpers"; interface Props { ep: TMDBSeasonDetailsEpisode; @@ -29,9 +30,22 @@ let isHidden: boolean = $state(!!store?.userSettings?.hideSpoilers); - const isUnaired = $derived( - ep.air_date && new Date(ep.air_date).getTime() > new Date().getTime(), - ); + const airDate: Date | undefined = $derived.by(() => { + if (!ep.air_date) { + return; + } + const d = new Date(ep.air_date); + if (isNaN(d.getTime())) { + return; + } + return d; + }); + const isUnaired: boolean = $derived.by(() => { + if (!airDate) { + return false; + } + return airDate.getTime() > new Date().getTime(); + }); /** * Re-sets `isHidden` state. @@ -117,18 +131,23 @@ > {/if} - - * - {Math.round(ep.vote_average * 10) / 10} - + {#if ep.vote_count <= 0 && isUnaired} + + {:else} + + * + {Math.round(ep.vote_average * 10) / 10} + + {/if} - {#if isUnaired} - Airs on {new Date(ep.air_date).toLocaleDateString()} + {#if isUnaired && airDate} + + Airs on {toRelativeDate(airDate)} + {/if} {ep.overview}