Fetch all contacts to FE to prevent subsequent fetches on contact data

This commit is contained in:
Jack Kingsman
2026-01-19 12:19:23 -08:00
parent a8c34fbd9e
commit a7d0a8f20b
7 changed files with 565 additions and 548 deletions
+9 -1
View File
@@ -71,7 +71,15 @@ export function useUnreadCounts(
if (conversations.length === 0) return;
try {
const bulkMessages = await api.getMessagesBulk(conversations, UNREAD_FETCH_LIMIT);
// Fetch messages in chunks to avoid huge single requests
const chunkSize = 200;
const bulkMessages: Record<string, Message[]> = {};
for (let i = 0; i < conversations.length; i += chunkSize) {
const chunk = conversations.slice(i, i + chunkSize);
const chunkResult = await api.getMessagesBulk(chunk, UNREAD_FETCH_LIMIT);
Object.assign(bulkMessages, chunkResult);
}
const newUnreadCounts: Record<string, number> = {};
const newMentions: Record<string, boolean> = {};
const newLastMessageTimes: Record<string, number> = {};