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'.
This commit is contained in:
Classic298 authored and GitHub committed 2025-12-31 17:41:27 +04:00
1 parent 0bd295b10b
commit 6c203fc7df
1 file changed
+4
+4
View File
@@ -142,6 +142,10 @@ export const getChatList = async (
throw error;
}
if (!res) {
return [];
}
return res.map((chat) => ({
...chat,
time_range: getTimeRange(chat.updated_at)