Skip to content

Commit

Permalink
ability to add a new text message when using the changeMessage method
Browse files Browse the repository at this point in the history
  • Loading branch information
OvidijusParsiunas committed Nov 28, 2024
1 parent 7c7c3ce commit 4d12e86
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions component/src/views/chat/messages/messageUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,10 @@ export class MessageUtils {
msg.renderText(messageToEls[1].text.bubbleElement, newText);
} else {
const messageElements = msg.createElements(newText, messageToEls[0].role);
msg.elementRef.insertBefore(messageElements.outerContainer, msg.elementRef.firstChild);
// update messageElementRefs element reference
const nextElements = (messageToEls[1].html || messageToEls[1].files?.[0]) as MessageElements;
msg.elementRef.insertBefore(messageElements.outerContainer, nextElements.outerContainer);
const nextMsgElsIndex = msg.messageElementRefs.findIndex((messageElements) => messageElements === nextElements);
msg.messageElementRefs.splice(nextMsgElsIndex, 0, messageElements);
messageToEls[1].text = messageElements;
}
messageToEls[0].text = newText;
Expand Down

0 comments on commit 4d12e86

Please sign in to comment.