Skip to content

Commit

Permalink
fix(ChatSessions.vue): improve session initialization logic (#130)
Browse files Browse the repository at this point in the history
- Refactored `currentSessionId` watcher to be asynchronous for better handling of session updates.
- Enhanced `mounted` lifecycle hook to check if there are any existing sessions and create a new session if none exist.
  • Loading branch information
takanotume24 authored Dec 19, 2024
1 parent b255e29 commit 4461b17
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/ChatSessions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ export default defineComponent({
};
},
watch: {
currentSessionId(newVal: SessionId, _: SessionId) {
async currentSessionId(newVal: SessionId, _: SessionId) {
this.localCurrentSessionId = newVal;
},
},
async mounted() {
await this.fetchSessionIdList();
if (this.localCurrentSessionId == null && this.sessionIdList.length == 0) {
await this.createNewSession();
}
},
methods: {
selectSession(sessionId: SessionId) {
Expand Down

0 comments on commit 4461b17

Please sign in to comment.