fix: Cleared thread last message is not updated (#1225)
When a user clears the conversation in a thread, the last message displayed was still the old one. This led to confusion about whether or not the user had successfully cleared the conversation.
This commit is contained in:
parent
a7f186cc5e
commit
85641741cf
@ -22,6 +22,7 @@ import {
|
||||
setActiveThreadIdAtom,
|
||||
deleteThreadStateAtom,
|
||||
threadStatesAtom,
|
||||
updateThreadStateLastMessageAtom,
|
||||
} from '@/helpers/atoms/Thread.atom'
|
||||
|
||||
export default function useDeleteThread() {
|
||||
@ -33,21 +34,23 @@ export default function useDeleteThread() {
|
||||
const deleteMessages = useSetAtom(deleteChatMessagesAtom)
|
||||
const cleanMessages = useSetAtom(cleanChatMessagesAtom)
|
||||
const deleteThreadState = useSetAtom(deleteThreadStateAtom)
|
||||
|
||||
const threadStates = useAtomValue(threadStatesAtom)
|
||||
const updateThreadLastMessage = useSetAtom(updateThreadStateLastMessageAtom)
|
||||
|
||||
const cleanThread = async (threadId: string) => {
|
||||
if (threadId) {
|
||||
const thread = threads.filter((c) => c.id === threadId)[0]
|
||||
cleanMessages(threadId)
|
||||
|
||||
if (thread)
|
||||
if (thread) {
|
||||
await extensionManager
|
||||
.get<ConversationalExtension>(ExtensionType.Conversational)
|
||||
?.writeMessages(
|
||||
threadId,
|
||||
messages.filter((msg) => msg.role === ChatCompletionRole.System)
|
||||
)
|
||||
updateThreadLastMessage(threadId, undefined)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user