This commit is contained in:
Timothy Jaeryang Baek
2026-03-17 18:52:02 -05:00
parent b8ea267f8e
commit 58e78e8946
7 changed files with 24 additions and 8 deletions
@@ -128,7 +128,9 @@
user_id: c.user_id,
user_name: c.user_name
}));
chatList = [...chatList, ...newChats];
const existingIds = new Set(chatList.map((c) => c.id));
const uniqueNewChats = newChats.filter((c) => !existingIds.has(c.id));
chatList = [...chatList, ...uniqueNewChats];
allChatsLoaded = chats.length < PAGE_SIZE;
} catch (err) {
console.error('Failed to load more chats:', err);
@@ -81,7 +81,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;
@@ -78,7 +78,9 @@
}
if (selectedFileItems) {
selectedFileItems = [...selectedFileItems, ...pageItems];
const existingIds = new Set(selectedFileItems.map((item) => item.id));
const newItems = pageItems.filter((item) => !existingIds.has(item.id));
selectedFileItems = [...selectedFileItems, ...newItems];
} else {
selectedFileItems = pageItems;
}
@@ -137,7 +139,9 @@
}
if (items) {
items = [...items, ...pageItems];
const existingIds = new Set(items.map((item) => item.id));
const newItems = pageItems.filter((item) => !existingIds.has(item.id));
items = [...items, ...newItems];
} else {
items = pageItems;
}
+3 -1
View File
@@ -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;
+3 -1
View File
@@ -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;
};
+3 -1
View File
@@ -221,7 +221,9 @@
}
if (items) {
items = [...items, ...pageItems];
const existingIds = new Set(items.map((item) => item.id));
const newItems = pageItems.filter((item) => !existingIds.has(item.id));
items = [...items, ...newItems];
} else {
items = pageItems;
}
@@ -101,7 +101,9 @@
}
if (items) {
items = [...items, ...pageItems];
const existingIds = new Set(items.map((item) => item.id));
const newItems = pageItems.filter((item) => !existingIds.has(item.id));
items = [...items, ...newItems];
} else {
items = pageItems;
}