Fix the bug of conversation title

This commit is contained in:
Rafi
2023-04-01 21:54:15 +08:00
parent f20a3562f3
commit 8ff914582a
3 changed files with 8 additions and 8 deletions

View File

@@ -54,7 +54,6 @@ const deleteConversation = async (index) => {
deletingConversationIndex.value = null deletingConversationIndex.value = null
if (!error.value) { if (!error.value) {
if (conversations.value[index].id === currentConversation.value.id) { if (conversations.value[index].id === currentConversation.value.id) {
console.log('delete current conversation')
createNewConversation() createNewConversation()
} }
conversations.value.splice(index, 1) conversations.value.splice(index, 1)
@@ -331,14 +330,14 @@ onMounted(async () => {
> >
<v-app-bar-nav-icon @click="drawer = !drawer"></v-app-bar-nav-icon> <v-app-bar-nav-icon @click="drawer = !drawer"></v-app-bar-nav-icon>
<v-toolbar-title>{{ currentConversation.topic ?? runtimeConfig.public.appName }}</v-toolbar-title> <v-toolbar-title>{{ currentConversation.id ? currentConversation.topic : runtimeConfig.public.appName }}</v-toolbar-title>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-btn <v-btn
:title="$t('newConversation')" :title="$t('newConversation')"
icon="add" icon="add"
@click="createNewConversation()" @click="createNewConversation"
class="d-md-none" class="d-md-none"
></v-btn> ></v-btn>
<v-btn <v-btn

View File

@@ -11,7 +11,8 @@ const conversation = ref(getDefaultConversationData())
const loadConversation = async () => { const loadConversation = async () => {
const { data, error } = await useAuthFetch('/api/chat/conversations/' + route.params.id) const { data, error } = await useAuthFetch('/api/chat/conversations/' + route.params.id)
if (!error.value) { if (!error.value) {
conversation.value = data.value conversation.value = Object.assign(conversation.value, data.value)
console.log(conversation.value)
} }
} }
@@ -24,7 +25,6 @@ const loadMessage = async () => {
onActivated(async () => { onActivated(async () => {
console.log('activated') console.log('activated')
console.log(conversation.value)
if (route.params.id) { if (route.params.id) {
conversation.value.loadingMessages = true conversation.value.loadingMessages = true
await loadConversation() await loadConversation()
@@ -33,9 +33,12 @@ onActivated(async () => {
} else { } else {
conversation.value = getDefaultConversationData() conversation.value = getDefaultConversationData()
} }
console.log(conversation.value)
currentConversation.value = Object.assign({}, conversation.value) currentConversation.value = Object.assign({}, conversation.value)
}) })
watchEffect(() => {
console.log('conversation.value', conversation.value)
})
</script> </script>
<template> <template>

View File

@@ -18,8 +18,6 @@ export const getConversations = async () => {
} }
export const createNewConversation = () => { export const createNewConversation = () => {
const conversation = useConversation()
conversation.value = getDefaultConversationData()
navigateTo('/') navigateTo('/')
} }