mirror of
https://github.com/ArthurDanjou/artchat.git
synced 2026-01-14 13:54:01 +01:00
feat: add duplicate message check and update chat UI styles
This commit is contained in:
@@ -20,7 +20,7 @@ const formatted = computed(() => useDateFormat(useNow(), 'D MMMM YYYY, HH:mm', {
|
||||
<div class="flex flex-col-reverse gap-4 md:flex-row-reverse items-end">
|
||||
<UCard
|
||||
variant="solid"
|
||||
class="rounded-xl mt-1 bg-sky-300 md:max-w-3/4"
|
||||
class="rounded-xl mt-1 bg-sky-500 md:max-w-3/4 text-white font-medium"
|
||||
:ui="{ body: 'sm:p-2', header: 'sm:p-2', footer: 'sm:p-2' }"
|
||||
>
|
||||
<div class="text-justify">
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }
|
||||
})
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 1.4 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 202 KiB After Width: | Height: | Size: 1.4 MiB |
Reference in New Issue
Block a user