From 9712f5605471a673edb3d25048dc08d1addd58db Mon Sep 17 00:00:00 2001 From: Gauthier Date: Sat, 22 Feb 2025 17:18:27 +0100 Subject: [PATCH] fix: fix remove from *arr in item details (#1387) Fix the "Remove From *arr" button in the slideover of the movie/series details page. The issue was caused by an attempt to delete a file that didn't exist. --- src/components/ManageSlideOver/index.tsx | 8 +++----- src/components/RequestList/RequestItem/index.tsx | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/ManageSlideOver/index.tsx b/src/components/ManageSlideOver/index.tsx index 205c9456f..5c36e787d 100644 --- a/src/components/ManageSlideOver/index.tsx +++ b/src/components/ManageSlideOver/index.tsx @@ -122,15 +122,13 @@ const ManageSlideOver = ({ const deleteMediaFile = async () => { if (data.mediaInfo) { - const res1 = await fetch(`/api/v1/media/${data.mediaInfo.id}/file`, { + // we don't check if the response is ok here because there may be no file to delete + await fetch(`/api/v1/media/${data.mediaInfo.id}/file`, { method: 'DELETE', }); - if (!res1.ok) throw new Error(); - - const res2 = await fetch(`/api/v1/media/${data.mediaInfo.id}`, { + await fetch(`/api/v1/media/${data.mediaInfo.id}`, { method: 'DELETE', }); - if (!res2.ok) throw new Error(); revalidate(); onClose(); diff --git a/src/components/RequestList/RequestItem/index.tsx b/src/components/RequestList/RequestItem/index.tsx index 0f8a5a242..018fa9154 100644 --- a/src/components/RequestList/RequestItem/index.tsx +++ b/src/components/RequestList/RequestItem/index.tsx @@ -348,6 +348,7 @@ const RequestItem = ({ request, revalidateList }: RequestItemProps) => { const deleteMediaFile = async () => { if (request.media) { + // we don't check if the response is ok here because there may be no file to delete await fetch(`/api/v1/media/${request.media.id}/file`, { method: 'DELETE', });