From 3ee6f9200cb040c7ad910294da3a9415dc84e71a Mon Sep 17 00:00:00 2001 From: fallenbagel <98979876+fallenbagel@users.noreply.github.com> Date: Thu, 30 Jul 2026 00:49:56 +0500 Subject: [PATCH] fix: don't delete requests when removing media from arr (#3288) --- server/entity/Media.ts | 26 +++++++++++-------- server/routes/media.ts | 8 ++++++ src/components/ManageSlideOver/index.tsx | 1 - .../RequestList/RequestItem/index.tsx | 1 - 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/server/entity/Media.ts b/server/entity/Media.ts index a63003df6..304d80e8c 100644 --- a/server/entity/Media.ts +++ b/server/entity/Media.ts @@ -203,17 +203,21 @@ class Media { Object.assign(this, init); } - public resetServiceData(): void { - this.serviceId = null; - this.serviceId4k = null; - this.externalServiceId = null; - this.externalServiceId4k = null; - this.externalServiceSlug = null; - this.externalServiceSlug4k = null; - this.ratingKey = null; - this.ratingKey4k = null; - this.jellyfinMediaId = null; - this.jellyfinMediaId4k = null; + public resetServiceData(is4k?: boolean): void { + if (is4k === undefined || !is4k) { + this.serviceId = null; + this.externalServiceId = null; + this.externalServiceSlug = null; + this.ratingKey = null; + this.jellyfinMediaId = null; + } + if (is4k === undefined || is4k) { + this.serviceId4k = null; + this.externalServiceId4k = null; + this.externalServiceSlug4k = null; + this.ratingKey4k = null; + this.jellyfinMediaId4k = null; + } } @AfterLoad() diff --git a/server/routes/media.ts b/server/routes/media.ts index 1626de95b..2295f0021 100644 --- a/server/routes/media.ts +++ b/server/routes/media.ts @@ -280,8 +280,16 @@ mediaRoutes.delete( throw new Error('TVDB ID not found'); } await (service as SonarrAPI).removeSeries(tvdbId); + + for (const season of media.seasons) { + season[is4k ? 'status4k' : 'status'] = MediaStatus.DELETED; + } } + media[is4k ? 'status4k' : 'status'] = MediaStatus.DELETED; + media.resetServiceData(is4k); + await mediaRepository.save(media); + return res.status(204).send(); } catch (e) { if (e instanceof EntityNotFoundError) { diff --git a/src/components/ManageSlideOver/index.tsx b/src/components/ManageSlideOver/index.tsx index 5be4d54c9..a6fd5a174 100644 --- a/src/components/ManageSlideOver/index.tsx +++ b/src/components/ManageSlideOver/index.tsx @@ -149,7 +149,6 @@ const ManageSlideOver = ({ await axios.delete( `/api/v1/media/${data.mediaInfo.id}/file?is4k=${is4k}` ); - await axios.delete(`/api/v1/media/${data.mediaInfo.id}`); } catch (e) { if (!axios.isAxiosError(e) || e.response?.status !== 404) { addToast(intl.formatMessage(messages.removemediaerror), { diff --git a/src/components/RequestList/RequestItem/index.tsx b/src/components/RequestList/RequestItem/index.tsx index b3d309eee..b53d4541e 100644 --- a/src/components/RequestList/RequestItem/index.tsx +++ b/src/components/RequestList/RequestItem/index.tsx @@ -359,7 +359,6 @@ const RequestItem = ({ request, revalidateList }: RequestItemProps) => { await axios.delete( `/api/v1/media/${request.media.id}/file?is4k=${request.is4k}` ); - await axios.delete(`/api/v1/media/${request.media.id}`); } catch (e) { if (!axios.isAxiosError(e) || e.response?.status !== 404) { addToast(intl.formatMessage(messages.removemediaerror), {