refac
This commit is contained in:
@@ -163,7 +163,9 @@
|
||||
allChatsLoaded = newChatList.length === 0;
|
||||
|
||||
if (newChatList.length > 0) {
|
||||
chatList = [...chatList, ...newChatList];
|
||||
const existingIds = new Set(chatList.map((c) => c.id));
|
||||
const uniqueNewChats = newChatList.filter((c) => !existingIds.has(c.id));
|
||||
chatList = [...chatList, ...uniqueNewChats];
|
||||
}
|
||||
|
||||
chatListLoading = false;
|
||||
|
||||
@@ -249,7 +249,9 @@
|
||||
|
||||
// once the bottom of the list has been reached (no results) there is no need to continue querying
|
||||
allChatsLoaded = newChatList.length === 0;
|
||||
await chats.set([...($chats ? $chats : []), ...newChatList]);
|
||||
const existingIds = new Set(($chats ?? []).map((c) => c.id));
|
||||
const uniqueNewChats = newChatList.filter((c) => !existingIds.has(c.id));
|
||||
await chats.set([...($chats ? $chats : []), ...uniqueNewChats]);
|
||||
|
||||
chatListLoading = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user