From c792faa042d019ffa962c597adbb1521230d7ece Mon Sep 17 00:00:00 2001 From: flashwave Date: Tue, 20 Feb 2024 20:58:01 +0000 Subject: [PATCH] Only emit umi:ui:message_add event when we're actually generating an element. --- src/mami.js/ui/messages.jsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/mami.js/ui/messages.jsx b/src/mami.js/ui/messages.jsx index 9c57c78..7d338db 100644 --- a/src/mami.js/ui/messages.jsx +++ b/src/mami.js/ui/messages.jsx @@ -11,18 +11,16 @@ #include ui/emotes.js Umi.UI.Messages = (function() { - let forceUserInfo = false, - lastMsgUser = null, - lastMsgChannel = null, - lastWasTiny = null; + let forceUserInfo = false; + let lastMsgUser = null; + let lastMsgChannel = null; + let lastWasTiny = null; const title = new MamiWindowTitle({ getName: () => futami.get('title'), }); - window.addEventListener('focus', function() { - title.clear(); - }); + window.addEventListener('focus', () => title.clear()); const botMsgs = { 'say': { text: '%0' }, @@ -393,7 +391,7 @@ Umi.UI.Messages = (function() { mami.sound.library.play(soundName, soundVolume, soundRate); } - if(window.CustomEvent) + if(eBase instanceof HTMLElement) window.dispatchEvent(new CustomEvent('umi:ui:message_add', { detail: { element: eBase,