diff --git a/src/components/ChatWindow/ChatWindow.ts b/src/components/ChatWindow/ChatWindow.ts index d18abb00..af1a6c34 100644 --- a/src/components/ChatWindow/ChatWindow.ts +++ b/src/components/ChatWindow/ChatWindow.ts @@ -140,6 +140,8 @@ export default class ChatWindow extends BaseComponent { id: 0, createdAt: new Date().toISOString(), }); + + this.emit('new-message', text); } private handleMessageReceive(event: MessageEvent) { @@ -154,6 +156,7 @@ export default class ChatWindow extends BaseComponent { console.log(`[message] Данные получены с сервера: ${message}`); if ('content' in message) { + this.emit('new-message', message.content); this.addNewMessageElement(message); this.messagesContainer.scrollTop = diff --git a/src/pages/ChatPage/ChatPage.hbs b/src/pages/ChatPage/ChatPage.hbs index 777284c9..c07bcb7a 100644 --- a/src/pages/ChatPage/ChatPage.hbs +++ b/src/pages/ChatPage/ChatPage.hbs @@ -1,14 +1,21 @@
{{this.authorName}}
-{{this.lastMessage}}
+{{this.lastMessage}}