fix: Render chat messages using updateMessageBlock
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { getContext } from '../../../../../../extensions.js';
|
import { getContext } from '../../../../../../extensions.js';
|
||||||
import { chat, user_avatar, setExtensionPrompt, extension_prompt_types } from '../../../../../../../script.js';
|
import { chat, user_avatar, setExtensionPrompt, extension_prompt_types, updateMessageBlock } from '../../../../../../../script.js';
|
||||||
|
|
||||||
// Core modules
|
// Core modules
|
||||||
import {
|
import {
|
||||||
@@ -167,13 +167,9 @@ export async function onMessageReceived(data) {
|
|||||||
renderQuests();
|
renderQuests();
|
||||||
|
|
||||||
// Then update the DOM to reflect the cleaned message
|
// Then update the DOM to reflect the cleaned message
|
||||||
const lastMessageElement = $('#chat').children('.mes').last();
|
// Using updateMessageBlock to perform macro substitutions + regex formatting
|
||||||
if (lastMessageElement.length) {
|
const messageId = chat.length - 1;
|
||||||
const messageText = lastMessageElement.find('.mes_text');
|
updateMessageBlock(messageId, lastMessage, { rerenderMessage: true });
|
||||||
if (messageText.length) {
|
|
||||||
messageText.html(substituteParams(cleanedMessage.trim()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log('[RPG Companion] Cleaned message, removed tracker code blocks from DOM');
|
// console.log('[RPG Companion] Cleaned message, removed tracker code blocks from DOM');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user