fix: no attachment broadcast fix

This commit is contained in:
gosangam
2026-08-29 18:56:45 +05:30
parent 03c8799f22
commit 0f382ed885
4 changed files with 18 additions and 5 deletions
+8 -2
View File
@@ -18,8 +18,14 @@ async function call<T>(path: string, init?: RequestInit): Promise<T> {
});
if (!res.ok) throw new Error(`broadcast request failed: ${res.status}`);
if (res.status === 204) return undefined as T;
const json = await res.json();
return (json?.data ?? json) as T;
const body = (await res.json().catch(() => ({}))) as {
data?: T;
success?: boolean;
};
// NOT `body.data ?? body`: /pending answers {data: null} when nothing is
// waiting, and `??` would fall through and hand back the whole envelope —
// which is truthy, so the modal would try to render it as an announcement.
return (body.data ?? (null as unknown as T)) as T;
}
export type Broadcast = {