fix: status will now stay deleted after declined request

pull/3460/head
Brandon Cohen 2 years ago committed by OwsleyJr
parent d5e3f1cd0b
commit 5c3ea9b036

@ -167,7 +167,8 @@ export class MediaRequest {
// If there is an existing movie request that isn't declined, don't allow a new one.
if (
requestBody.mediaType === MediaType.MOVIE &&
existing[0].status !== MediaRequestStatus.DECLINED
existing[0].status !== MediaRequestStatus.DECLINED &&
existing[0].status !== MediaRequestStatus.COMPLETED
) {
logger.warn('Duplicate request for media blocked', {
tmdbId: tmdbMedia.id,
@ -260,7 +261,8 @@ export class MediaRequest {
.filter(
(request) =>
request.is4k === requestBody.is4k &&
request.status !== MediaRequestStatus.DECLINED
request.status !== MediaRequestStatus.DECLINED &&
request.status !== MediaRequestStatus.COMPLETED
)
.reduce((seasons, request) => {
const combinedSeasons = request.seasons.map(
@ -279,7 +281,9 @@ export class MediaRequest {
.filter(
(season) =>
season[requestBody.is4k ? 'status4k' : 'status'] !==
MediaStatus.UNKNOWN
MediaStatus.UNKNOWN &&
season[requestBody.is4k ? 'status4k' : 'status'] !==
MediaStatus.DELETED
)
.map((season) => season.seasonNumber),
];
@ -583,7 +587,8 @@ export class MediaRequest {
if (
media.mediaType === MediaType.MOVIE &&
this.status === MediaRequestStatus.DECLINED
this.status === MediaRequestStatus.DECLINED &&
media[this.is4k ? 'status4k' : 'status'] !== MediaStatus.DELETED
) {
media[this.is4k ? 'status4k' : 'status'] = MediaStatus.UNKNOWN;
mediaRepository.save(media);
@ -601,7 +606,8 @@ export class MediaRequest {
media.requests.filter(
(request) => request.status === MediaRequestStatus.PENDING
).length === 0 &&
media[this.is4k ? 'status4k' : 'status'] === MediaStatus.PENDING
media[this.is4k ? 'status4k' : 'status'] === MediaStatus.PENDING &&
media[this.is4k ? 'status4k' : 'status'] !== MediaStatus.DELETED
) {
media[this.is4k ? 'status4k' : 'status'] = MediaStatus.UNKNOWN;
mediaRepository.save(media);

@ -400,7 +400,8 @@ requestRoutes.put<{ requestId: string }>(
(r) =>
r.is4k === request.is4k &&
r.id !== request.id &&
r.status !== MediaRequestStatus.DECLINED
r.status !== MediaRequestStatus.DECLINED &&
r.status !== MediaRequestStatus.COMPLETED
)
.reduce((seasons, r) => {
const combinedSeasons = r.seasons.map(

@ -266,7 +266,7 @@ const RequestButton = ({
if (
(!media ||
media.status === MediaStatus.UNKNOWN ||
media.status === MediaStatus.DELETED) &&
(media.status === MediaStatus.DELETED && !activeRequest)) &&
hasPermission(
[
Permission.REQUEST,
@ -311,7 +311,7 @@ const RequestButton = ({
if (
(!media ||
media.status4k === MediaStatus.UNKNOWN ||
media.status4k === MediaStatus.DELETED) &&
(media.status4k === MediaStatus.DELETED && !active4kRequest)) &&
hasPermission(
[
Permission.REQUEST_4K,

@ -16,7 +16,7 @@ import {
TrashIcon,
XMarkIcon,
} from '@heroicons/react/24/solid';
import { MediaRequestStatus } from '@server/constants/media';
import { MediaRequestStatus, MediaStatus } from '@server/constants/media';
import type { MediaRequest } from '@server/entity/MediaRequest';
import type { MovieDetails } from '@server/models/Movie';
import type { TvDetails } from '@server/models/Tv';
@ -411,6 +411,15 @@ const RequestCard = ({ request, onTitleData }: RequestCardProps) => {
>
{intl.formatMessage(globalMessages.failed)}
</Badge>
) : requestData.status === MediaRequestStatus.PENDING &&
requestData.media[requestData.is4k ? 'status4k' : 'status'] ===
MediaStatus.DELETED ? (
<Badge
badgeType="warning"
href={`/${requestData.type}/${requestData.media.tmdbId}?manage=1`}
>
{intl.formatMessage(globalMessages.pending)}
</Badge>
) : (
<StatusBadge
status={

@ -15,7 +15,7 @@ import {
TrashIcon,
XMarkIcon,
} from '@heroicons/react/24/solid';
import { MediaRequestStatus } from '@server/constants/media';
import { MediaRequestStatus, MediaStatus } from '@server/constants/media';
import type { MediaRequest } from '@server/entity/MediaRequest';
import type { MovieDetails } from '@server/models/Movie';
import type { TvDetails } from '@server/models/Tv';
@ -474,6 +474,15 @@ const RequestItem = ({ request, revalidateList }: RequestItemProps) => {
>
{intl.formatMessage(globalMessages.failed)}
</Badge>
) : requestData.status === MediaRequestStatus.PENDING &&
requestData.media[requestData.is4k ? 'status4k' : 'status'] ===
MediaStatus.DELETED ? (
<Badge
badgeType="warning"
href={`/${requestData.type}/${requestData.media.tmdbId}?manage=1`}
>
{intl.formatMessage(globalMessages.pending)}
</Badge>
) : (
<StatusBadge
status={

@ -207,7 +207,9 @@ const TitleCard = ({
<div
className={`px-2 text-white ${
!showRequestButton ||
(currentStatus && currentStatus !== MediaStatus.UNKNOWN)
(currentStatus &&
currentStatus !== MediaStatus.UNKNOWN &&
currentStatus !== MediaStatus.DELETED)
? 'pb-2'
: 'pb-11'
}`}
@ -235,7 +237,8 @@ const TitleCard = ({
WebkitLineClamp:
!showRequestButton ||
(currentStatus &&
currentStatus !== MediaStatus.UNKNOWN)
currentStatus !== MediaStatus.UNKNOWN &&
currentStatus !== MediaStatus.DELETED)
? 5
: 3,
display: '-webkit-box',
@ -253,7 +256,9 @@ const TitleCard = ({
<div className="absolute bottom-0 left-0 right-0 flex justify-between px-2 py-2">
{showRequestButton &&
(!currentStatus || currentStatus === MediaStatus.UNKNOWN) && (
(!currentStatus ||
currentStatus === MediaStatus.UNKNOWN ||
currentStatus === MediaStatus.DELETED) && (
<Button
buttonType="primary"
buttonSize="sm"

@ -234,7 +234,8 @@ const TvDetails = ({ tv }: TvDetailsProps) => {
.filter(
(request) =>
request.is4k === is4k &&
request.status !== MediaRequestStatus.DECLINED
request.status !== MediaRequestStatus.DECLINED &&
request.status !== MediaRequestStatus.COMPLETED
)
.reduce((requestedSeasons, request) => {
return [

Loading…
Cancel
Save