From 63880feeb1354e487f6575f5a899bef4073eb14a Mon Sep 17 00:00:00 2001 From: jtrzupek Date: Sun, 7 Jun 2026 19:24:29 +0200 Subject: [PATCH] =?UTF-8?q?fix(mobile/api):=20handle=20204=20in=20request(?= =?UTF-8?q?)=20=E2=80=94=20"Mark=20as=20invalid"=20false=20failure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The generic request() always called res.json(), which throws on a 204 No Content body. mark-dead endpoints (scene + movie "Mark as invalid"/broken) return 204, so the call threw AFTER the backend had already marked the source dead → user saw a "Failed" alert and the list didn't refresh, even though the mark succeeded server-side (bug-reports 2026-05-28 Voe, 2026-06-03 scene 1e8dc190). Return undefined for 204 before parsing JSON. Co-Authored-By: Claude Opus 4.8 --- mobile/src/api.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mobile/src/api.ts b/mobile/src/api.ts index de700da..8265322 100644 --- a/mobile/src/api.ts +++ b/mobile/src/api.ts @@ -67,6 +67,12 @@ export class GoonClient { const text = await res.text().catch(() => res.statusText); throw new ApiError(res.status, `${res.status}: ${text}`); } + // 204 No Content (np. mark-dead endpoints) — puste body, `res.json()` rzuciłby + // "JSON Parse error". To powodowało fałszywy "Failed" alert przy "Mark as invalid" + // mimo że backend POPRAWNIE oznaczał link dead (bug-report 2026-05-28 Voe + 06-03). + if (res.status === 204) { + return undefined as T; + } const data = (await res.json()) as T; // Backend zwraca path-only `/proxy/...` dla CDN-ów wymagających Referera // (thumbnails, stream URLs). Klient prefixuje baseUrl-em rekursywnie tak żeby