fix: handle partial seasons more reliably (#4116)

refactor: remove matchingOldSeason variable
This commit is contained in:
Brandon Cohen
2025-04-18 18:20:30 -05:00
committed by GitHub
parent 064ae92134
commit 8cd53cdc3c
3 changed files with 50 additions and 50 deletions

View File

@@ -58,19 +58,16 @@ export class MediaRequestSubscriber
// Find all seasons in the related media entity
// and see if they are available, then we can check
// if the request contains the same seasons
const requestedSeasons =
entity.seasons?.map((entitySeason) => entitySeason.seasonNumber) ?? [];
const availableSeasons = entity.media.seasons.filter(
(season) =>
season[entity.is4k ? 'status4k' : 'status'] === MediaStatus.AVAILABLE
season[entity.is4k ? 'status4k' : 'status'] === MediaStatus.AVAILABLE &&
requestedSeasons.includes(season.seasonNumber)
);
const isMediaAvailable =
availableSeasons.length > 0 &&
availableSeasons.every((availableSeason) =>
entity.seasons?.some(
(entitySeason) =>
entitySeason.seasonNumber === availableSeason.seasonNumber
)
);
availableSeasons.length === requestedSeasons.length;
if (
entity.media[entity.is4k ? 'status4k' : 'status'] ===