Skip to content

Commit

Permalink
update only if edit = True (#445)
Browse files Browse the repository at this point in the history
  • Loading branch information
swuecho authored May 21, 2024
1 parent f43d87a commit 561ffba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions web/src/store/modules/chat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ export const useChatStore = defineStore('chat-store', {
}
},

async updateChatSessionIfEdited(uuid: string, edit: Partial<Chat.Session>) {
const index = this.history.findIndex(item => item.uuid === uuid)
if (index !== -1) {
// set inactive session to edit mode = false
if (this.history[index].isEdit) {
this.history[index] = { ...this.history[index], ...edit }
await fetchUpdateChatByUuid(uuid, this.history[index])
}
}
},

deleteChatSession(index: number) {
deleteChatSession(this.history[index].uuid)
delete this.chat[this.history[index].uuid]
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/chat/layout/sider/List.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function handleSelect( uuid: string ) {
return
if (chatStore.active)
await chatStore.updateChatSession(chatStore.active, { isEdit: false })
await chatStore.updateChatSessionIfEdited(chatStore.active, { isEdit: false })
await chatStore.setActive(uuid)
Expand Down

0 comments on commit 561ffba

Please sign in to comment.