feat: add duplicate message check and update chat UI styles

This commit is contained in:
2025-09-02 18:30:34 +02:00
parent 01bbb6c00a
commit 204ded71e5
5 changed files with 11 additions and 3 deletions

View File

@@ -9,6 +9,13 @@ export const useChatStore = defineStore('chat', () => {
return !messages.value.some(msg => msg.state === ChatState.LOADING)
})
function checkForDuplicateMessages(type: ChatType) {
const duplicate = messages.value.findLast(msg => msg.type === type)
if (duplicate) {
messages.value.splice(messages.value.indexOf(duplicate) - 1, 2)
}
}
function addMessage(type: ChatType, content: string, sender: ChatSender, fetchStates: ChatFetchState[]) {
if (sender === ChatSender.ARTHUR) {
const message: ChatMessage = {
@@ -46,5 +53,5 @@ export const useChatStore = defineStore('chat', () => {
}
}
return { messages, addMessage, clearMessages, canSend, setLoadingState }
return { messages, addMessage, clearMessages, canSend, setLoadingState, checkForDuplicateMessages }
})