fix (#272) add listener only to needed chat messages

This commit is contained in:
Samuel Lopez
2025-12-05 08:47:46 +01:00
committed by samulopez
parent 58a11b7925
commit 12574184d8
+11 -1
View File
@@ -190,7 +190,7 @@ Hooks.on("renderGamePause", function (_, html, options) {
}
});
Hooks.on("renderChatMessageHTML", async (app, element, context, options) => {
function addEventListenerToChatMessage(element) {
element.addEventListener("click", (event) => {
const btnWithAction = event.target.closest("button[data-action]");
const message = event.target.closest("li[data-message-id]");
@@ -200,4 +200,14 @@ Hooks.on("renderChatMessageHTML", async (app, element, context, options) => {
handleInlineActions(btnWithAction, messageId);
}
});
}
Hooks.on("renderChatLog", async (app, element) => {
addEventListenerToChatMessage(element);
});
Hooks.on("renderChatMessageHTML", async (app, element, context) => {
// ignore non chat card notifications
if (!context.canClose) return;
addEventListenerToChatMessage(element);
});