From 469dfeeac3acffe10b0f7cf374fb7f0d11ecd90f Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.net>
Date: Sun, 1 Mar 2026 19:56:11 -0800
Subject: fix(match): prevent cached airing injection mutation regressions

---
 src/lib/List/Anime/UpcomingAnimeList.svelte | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

(limited to 'src/lib/List/Anime/UpcomingAnimeList.svelte')

diff --git a/src/lib/List/Anime/UpcomingAnimeList.svelte b/src/lib/List/Anime/UpcomingAnimeList.svelte
index 2dd69a68..4bd7a287 100644
--- a/src/lib/List/Anime/UpcomingAnimeList.svelte
+++ b/src/lib/List/Anime/UpcomingAnimeList.svelte
@@ -60,16 +60,19 @@ const cleanMedia = (
 						? media.mediaListEntry?.status === "PLANNING"
 						: false) || !hasDueEpisodes(media),
 			)
-			.map((media: Media) => {
+			.map((media: Media) =>
 				// Adjust for planned anime
-				if (
-					($settings.displayPlannedAnime ? media.episodes !== 1 : true) &&
-					hasNoAiredEpisodes(media)
-				)
-					media.nextAiringEpisode = { episode: -1 };
-
-				return media;
-			});
+				($settings.displayPlannedAnime ? media.episodes !== 1 : true) &&
+				hasNoAiredEpisodes(media)
+					? {
+							...media,
+							nextAiringEpisode: {
+								...(media.nextAiringEpisode || { episode: 0 }),
+								episode: -1,
+							},
+						}
+					: media,
+			);
 	let upcomingAnime = filterAnime(
 		plannedOnly ? "NOT_YET_RELEASED" : "RELEASING",
 	);
-- 
cgit v1.2.3

