Optimize fetching recent chats by using Promise.all for concurrent data retrieval

This commit is contained in:
Cohee
2025-05-13 20:41:26 +03:00
parent 241f718df7
commit 5a799042b1

View File

@ -261,7 +261,7 @@ async function getRecentChats() {
};
/** @type {RecentChat[]} */
const data = [...await charData(), ...await groupData()];
const data = await Promise.all([charData(), groupData()]).then(res => res.flat());
data.sort((a, b) => sortMoments(timestampToMoment(a.last_mes), timestampToMoment(b.last_mes)))
.map(chat => ({ chat, character: characters.find(x => x.avatar === chat.avatar), group: groups.find(x => x.id === chat.group) }))