Skip to content

Commit 44ec025

Browse files
committed
reset chat for new user
1 parent ad5065e commit 44ec025

File tree

1 file changed

+17
-5
lines changed
  • frontend/src/components/app/matches

1 file changed

+17
-5
lines changed

frontend/src/components/app/matches/Chat.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,26 @@ export default {
9595
this.scrollChatToBottom();
9696
}
9797
},
98+
async prepareChatForNewUser() {
99+
const messagesRequest = await this.$http.get(`/conversations/${this.chatWithUserId}`);
100+
this.messages = messagesRequest.data.messages;
101+
const userRequest = await this.$http.get(`/users/${this.chatWithUserId}`);
102+
this.user = userRequest.data;
103+
this.scrollChatToBottom();
104+
},
105+
},
106+
watch: {
107+
chatWithUserId: {
108+
async handler() {
109+
if (this.chatWithUserId) {
110+
await this.prepareChatForNewUser();
111+
}
112+
},
113+
},
98114
},
99115
async beforeMount() {
100-
const messagesRequest = await this.$http.get(`/conversations/${this.chatWithUserId}`);
101-
this.messages = messagesRequest.data.messages;
102-
const userRequest = await this.$http.get(`/users/${this.chatWithUserId}`);
103-
this.user = userRequest.data;
116+
await this.prepareChatForNewUser();
104117
this.loggedInUserId = this.$store.getters.getLoggedInUser.id;
105-
this.scrollChatToBottom();
106118
this.fetchMessagesIntervalId = setInterval(this.fetchNewMessages, 1000);
107119
},
108120
beforeDestroy() {

0 commit comments

Comments
 (0)