diff --git a/app/components/chat/MessageContainer.vue b/app/components/chat/MessageContainer.vue index 4277a07..47efaec 100644 --- a/app/components/chat/MessageContainer.vue +++ b/app/components/chat/MessageContainer.vue @@ -20,7 +20,7 @@ const formatted = computed(() => useDateFormat(useNow(), 'D MMMM YYYY, HH:mm', {
diff --git a/app/composables/chat.ts b/app/composables/chat.ts index a066f19..031208d 100644 --- a/app/composables/chat.ts +++ b/app/composables/chat.ts @@ -136,9 +136,10 @@ export function useChat(t: any) { ] }) - const { addMessage } = useChatStore() + const { addMessage, checkForDuplicateMessages } = useChatStore() async function submitMessage(type: ChatType, prompt: string, fetchStates: ChatFetchState[]) { + checkForDuplicateMessages(type) addMessage( type, prompt, diff --git a/app/stores/chat.ts b/app/stores/chat.ts index 9078b8f..cd4ad5d 100644 --- a/app/stores/chat.ts +++ b/app/stores/chat.ts @@ -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 } }) diff --git a/public/arthur.webp b/public/arthur.webp index e5adc30..9a4ed2b 100644 Binary files a/public/arthur.webp and b/public/arthur.webp differ diff --git a/public/favicon.webp b/public/favicon.webp index 8baafe7..9a4ed2b 100644 Binary files a/public/favicon.webp and b/public/favicon.webp differ