From 6c203fc7df83fa5a02ccea386d80ad109d86c953 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 31 Dec 2025 14:41:27 +0100 Subject: [PATCH] fix: prevent getChatList crash on null API response (#20269) Add null check before calling .map() on the API response in getChatList(). When the fetch fails silently or returns null, the function now gracefully returns an empty array instead of crashing with 'Cannot read property map of null'. --- src/lib/apis/chats/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/apis/chats/index.ts b/src/lib/apis/chats/index.ts index 991574436..6b59cda20 100644 --- a/src/lib/apis/chats/index.ts +++ b/src/lib/apis/chats/index.ts @@ -142,6 +142,10 @@ export const getChatList = async ( throw error; } + if (!res) { + return []; + } + return res.map((chat) => ({ ...chat, time_range: getTimeRange(chat.updated_at)