mirror of
https://github.com/ArthurDanjou/artchat.git
synced 2026-01-29 23:28:13 +01:00
feat: implement duplicate message detection and display notification
This commit is contained in:
@@ -136,10 +136,10 @@ export function useChat(t: any) {
|
||||
]
|
||||
})
|
||||
|
||||
const { addMessage, checkForDuplicateMessages } = useChatStore()
|
||||
const { addMessage, checkForDuplicateMessages, deleteMessage, cleanDuplicatedMessages } = useChatStore()
|
||||
|
||||
async function submitMessage(type: ChatType, prompt: string, fetchStates: ChatFetchState[]) {
|
||||
checkForDuplicateMessages(type)
|
||||
const duplicates = checkForDuplicateMessages(type)
|
||||
addMessage(
|
||||
type,
|
||||
prompt,
|
||||
@@ -147,6 +147,17 @@ export function useChat(t: any) {
|
||||
[],
|
||||
)
|
||||
await new Promise(resolve => setTimeout(resolve, 700))
|
||||
if (duplicates.length > 0) {
|
||||
duplicates.forEach(msg => deleteMessage(msg.id, msg.type))
|
||||
cleanDuplicatedMessages()
|
||||
addMessage(
|
||||
ChatType.DUPLICATED,
|
||||
'',
|
||||
ChatSender.ARTHUR,
|
||||
[ChatFetchState.THINKING, ChatFetchState.DONE],
|
||||
)
|
||||
await new Promise(resolve => setTimeout(resolve, 700))
|
||||
}
|
||||
addMessage(
|
||||
type,
|
||||
'',
|
||||
|
||||
Reference in New Issue
Block a user