Skip to content

Commit 079cba3

Browse files
authored
fix(*): Add messages with spread (#1046)
* fix(*): Add messages with spread * fix(*): Update the chat's messages directly
1 parent eea5aa7 commit 079cba3

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

samples/interactions/chat/features/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ igc-avatar::part(base) {
105105

106106
this.chat.options = { ...this.chat.options, isTyping: true, suggestions: [] };
107107
const newMessage = e.detail;
108-
this.messages.push(newMessage);
108+
this.chat.messages = [ ...this.chat.messages, newMessage];
109109

110110
const responseMessage = {
111111
id: Date.now().toString(),
112112
text: 'Our support team is currently unavailable. We\'ll get back to you as soon as possible.',
113113
sender: 'support',
114114
timestamp: Date.now().toString(),
115115
};
116-
this.messages.push(responseMessage);
116+
this.chat.messages = [ ...this.chat.messages, responseMessage];
117117
this.chat.draftMessage = { text: '', attachments: [] };
118118
this.chat.options = { ...this.chat.options, isTyping: false};
119119
}

samples/interactions/chat/overview/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export class ChatOverview {
8383
public onMessageCreated = (e: CustomEvent) => {
8484
e.preventDefault();
8585
const newMessage = e.detail;
86-
this.messages.push(newMessage);
86+
this.chat.messages = [ ...this.chat.messages, newMessage];
8787
this.chat.options = { ...this.chat.options, isTyping: true, suggestions: [] };
8888

8989
const messageText = e.detail.text.toLowerCase();
@@ -99,7 +99,9 @@ export class ChatOverview {
9999
sender: 'support',
100100
timestamp: Date.now().toString(),
101101
};
102-
this.messages.push(responseMessage);
102+
103+
this.chat.messages = [ ...this.chat.messages, responseMessage];
104+
103105
this.chat.draftMessage = { text: '', attachments: [] };
104106
this.chat.options = { ...this.chat.options, isTyping: false};
105107
}

0 commit comments

Comments
 (0)