添加清理过时对话的功能,更新聊天管理器以支持删除旧版本,优化查找最新对话的逻辑,并在聊天历史视图中添加清理按钮。

This commit is contained in:
duanfuxiang
2025-07-03 12:15:07 +08:00
parent 923d98cae9
commit cd65d6b3de
3 changed files with 99 additions and 8 deletions

View File

@@ -17,6 +17,7 @@ type UseChatHistory = {
getChatMessagesById: (id: string) => Promise<ChatMessage[] | null>
updateConversationTitle: (id: string, title: string) => Promise<void>
chatList: ChatConversationMeta[]
cleanupOutdatedChats: () => Promise<number>
}
export function useChatHistory(): UseChatHistory {
@@ -111,11 +112,18 @@ export function useChatHistory(): UseChatHistory {
[chatManager, fetchChatList],
)
const cleanupOutdatedChats = useCallback(async (): Promise<number> => {
const count = await chatManager.cleanupOutdatedChats()
await fetchChatList()
return count
}, [chatManager, fetchChatList])
return {
createOrUpdateConversation,
deleteConversation,
getChatMessagesById,
updateConversationTitle,
chatList,
cleanupOutdatedChats,
}
}