File tree Expand file tree Collapse file tree 1 file changed +17
-5
lines changed
frontend/src/components/app/matches Expand file tree Collapse file tree 1 file changed +17
-5
lines changed Original file line number Diff line number Diff 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 () {
You can’t perform that action at this time.
0 commit comments