Only emit umi:ui:message_add event when we're actually generating an element.

This commit is contained in:
flash 2024-02-20 20:58:01 +00:00
parent cdabf80e1c
commit c792faa042

View file

@ -11,18 +11,16 @@
#include ui/emotes.js #include ui/emotes.js
Umi.UI.Messages = (function() { Umi.UI.Messages = (function() {
let forceUserInfo = false, let forceUserInfo = false;
lastMsgUser = null, let lastMsgUser = null;
lastMsgChannel = null, let lastMsgChannel = null;
lastWasTiny = null; let lastWasTiny = null;
const title = new MamiWindowTitle({ const title = new MamiWindowTitle({
getName: () => futami.get('title'), getName: () => futami.get('title'),
}); });
window.addEventListener('focus', function() { window.addEventListener('focus', () => title.clear());
title.clear();
});
const botMsgs = { const botMsgs = {
'say': { text: '%0' }, 'say': { text: '%0' },
@ -393,7 +391,7 @@ Umi.UI.Messages = (function() {
mami.sound.library.play(soundName, soundVolume, soundRate); mami.sound.library.play(soundName, soundVolume, soundRate);
} }
if(window.CustomEvent) if(eBase instanceof HTMLElement)
window.dispatchEvent(new CustomEvent('umi:ui:message_add', { window.dispatchEvent(new CustomEvent('umi:ui:message_add', {
detail: { detail: {
element: eBase, element: eBase,