fix(mobile/api): handle 204 in request() — "Mark as invalid" false failure

The generic request<T>() 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 <noreply@anthropic.com>
This commit is contained in:
jtrzupek 2026-06-07 19:24:29 +02:00
parent a196fcbcdb
commit 63880feeb1

View file

@ -67,6 +67,12 @@ export class GoonClient {
const text = await res.text().catch(() => res.statusText); const text = await res.text().catch(() => res.statusText);
throw new ApiError(res.status, `${res.status}: ${text}`); 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; const data = (await res.json()) as T;
// Backend zwraca path-only `/proxy/...` dla CDN-ów wymagających Referera // Backend zwraca path-only `/proxy/...` dla CDN-ów wymagających Referera
// (thumbnails, stream URLs). Klient prefixuje baseUrl-em rekursywnie tak żeby // (thumbnails, stream URLs). Klient prefixuje baseUrl-em rekursywnie tak żeby