Skip to content

Commit

Permalink
wrong chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Germey committed Dec 30, 2023
1 parent c1b24ef commit 69ddaa1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/components/chat/SidePanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
import { defineComponent } from 'vue';
import { ElSkeleton, ElInput } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CHAT_CONVERSATION, ROUTE_CHAT_CONVERSATION_NEW } from '@/router/constants';
import { ROUTE_CHAT_CONVERSATION } from '@/router/constants';
import { chatOperator } from '@/operators';
import { IChatConversation } from '@/operators/chat/models';
import { Status } from '@/store/common/models';
Expand Down
41 changes: 22 additions & 19 deletions src/pages/chat/Conversation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,18 @@ export default defineComponent({
},
computed: {
messages() {
return (
this.$store.state.chat.conversations?.find(
(conversation: IChatConversation) => conversation.id === this.$route.params.id?.toString()
)?.messages || []
);
return this.$store.state.chat.conversations?.find(
(conversation: IChatConversation) => conversation.id === this.$route.params.id?.toString()
)?.messages;
},
conversationId(): string | undefined {
return this.$route.params.id?.toString();
},
conversation() {
return this.$store.state.chat.conversations?.find(
(conversation: IChatConversation) => conversation.id === this.conversationId
);
},
application() {
return this.applications?.find((application: IApplication) => application.api?.id === this.model.apiId);
},
Expand All @@ -85,9 +88,21 @@ export default defineComponent({
return this.$store.state.chat.getApplicationsStatus === Status.Request;
}
},
watch: {
conversationId() {
if (!this.conversation) {
this.onCreateNewConversation(this.conversationId);
}
}
},
mounted() {
if (!this.conversation) {
this.onCreateNewConversation(this.conversationId);
}
},
methods: {
async onCreateNewConversation() {
const newConversationId = uuid();
async onCreateNewConversation(id?: string) {
const newConversationId = id || uuid();
await this.$router.push({
name: ROUTE_CHAT_CONVERSATION,
params: {
Expand Down Expand Up @@ -117,10 +132,6 @@ export default defineComponent({
this.question = '';
await this.onFetchAnswer();
},
async onFetchHistory(id?: string) {
const { data: data } = await chatOperator.getConversation(id || this.conversationId);
this.messages = data.messages || [];
},
async onFetchAnswer() {
const token = this.application?.credential?.token;
const endpoint = this.application?.api?.endpoint;
Expand Down Expand Up @@ -153,14 +164,6 @@ export default defineComponent({
content: response.answer,
state: IChatMessageState.ANSWERING
};
if (!this.conversationId) {
this.$router.push({
name: ROUTE_CHAT_CONVERSATION,
params: {
id: response.conversation_id
}
});
}
}
}
)
Expand Down

0 comments on commit 69ddaa1

Please sign in to comment.