fix(room): fix model/ai list response parsing in RoomSettingsPanel

The SDK wraps API responses as { data: { code, message, data: [...] } }.
Code was incorrectly accessing resp.data['200'] which doesn't exist.
Fix to use resp.data.data to reach the actual array.
This commit is contained in:
ZhenYi 2026-04-17 23:15:14 +08:00
parent 4f1ea95b58
commit 5ff45770ec

View File

@ -68,8 +68,8 @@ export const RoomSettingsPanel = memo(function RoomSettingsPanel({
setAiConfigsLoading(true); setAiConfigsLoading(true);
try { try {
const resp = await aiList({ path: { room_id: room.id } }); const resp = await aiList({ path: { room_id: room.id } });
const inner = (resp.data as Record<string, unknown>)?.['200'] as Record<string, unknown> | undefined; const inner = resp.data as { data?: RoomAiResponse[] } | undefined;
setAiConfigs(Array.isArray(inner?.['data']) ? (inner['data'] as RoomAiResponse[]) : []); setAiConfigs(Array.isArray(inner?.data) ? inner.data : []);
} catch { } catch {
// ignore // ignore
} finally { } finally {
@ -86,8 +86,8 @@ export const RoomSettingsPanel = memo(function RoomSettingsPanel({
setModelsLoading(true); setModelsLoading(true);
try { try {
const resp = await modelList({}); const resp = await modelList({});
const raw = resp.data as Record<string, unknown> | undefined; const inner = resp.data as { data?: ModelResponse[] } | undefined;
setAvailableModels(Array.isArray(raw?.['200']) ? (raw['200'] as ModelResponse[]) : []); setAvailableModels(Array.isArray(inner?.data) ? inner.data : []);
} catch { } catch {
toast.error('Failed to load models'); toast.error('Failed to load models');
} finally { } finally {