From c4e47ae76367e50db7504a197b0543e31373562e Mon Sep 17 00:00:00 2001 From: Ryan Cohen Date: Tue, 16 Aug 2022 17:16:06 +0900 Subject: [PATCH] fix: also remove available/partially available seasons from requests --- server/entity/MediaRequest.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/entity/MediaRequest.ts b/server/entity/MediaRequest.ts index 91a5f7104..a02733964 100644 --- a/server/entity/MediaRequest.ts +++ b/server/entity/MediaRequest.ts @@ -242,6 +242,22 @@ export class MediaRequest { }, [] as number[]); } + // We should also check seasons that are available/partially available but don't have existing requests + if (media.seasons) { + existingSeasons = [ + ...existingSeasons, + ...media.seasons + .filter( + (season) => + season[requestBody.is4k ? 'status4k' : 'status'] === + MediaStatus.AVAILABLE || + season[requestBody.is4k ? 'status4k' : 'status'] === + MediaStatus.PARTIALLY_AVAILABLE + ) + .map((season) => season.seasonNumber), + ]; + } + const finalSeasons = requestedSeasons.filter( (rs) => !existingSeasons.includes(rs) );