Record scroll test (#2783)

* perf: history add scrollList (#2696)

* perf: chatHistorySlider add virtualList

* perf: chat records add scrollList

* delete console

* perf: ScrollData add ref props

* 优化代码

* optimize code && add line breaks

* add total records display

* finish test

* perf: ScrollComponent load data

* perf: Scroll components load

* perf: scroll code

---------

Co-authored-by: papapatrick <109422393+Patrickill@users.noreply.github.com>
This commit is contained in:
Archer
2024-09-24 17:13:32 +08:00
committed by GitHub
parent f4d4d6516c
commit 434c03c955
46 changed files with 827 additions and 422 deletions

View File

@@ -9,23 +9,24 @@ import { MongoChat } from './chatSchema';
export async function getChatItems({
appId,
chatId,
limit = 30,
offset,
limit,
field
}: {
appId: string;
chatId?: string;
limit?: number;
offset: number;
limit: number;
field: string;
}): Promise<{ histories: ChatItemType[] }> {
}): Promise<{ histories: ChatItemType[]; total: number }> {
if (!chatId) {
return { histories: [] };
return { histories: [], total: 0 };
}
const histories = await MongoChatItem.find({ appId, chatId }, field)
.sort({ _id: -1 })
.limit(limit)
.lean();
const [histories, total] = await Promise.all([
MongoChatItem.find({ chatId, appId }, field).sort({ _id: -1 }).skip(offset).limit(limit).lean(),
MongoChatItem.countDocuments({ chatId, appId })
]);
histories.reverse();
histories.forEach((item) => {
@@ -33,7 +34,7 @@ export async function getChatItems({
item.value = adaptStringValue(item.value);
});
return { histories };
return { histories, total };
}
/* Temporary adaptation for old conversation records */