From bd8cadf104353def6af011a375a04c0b1f8ea74c Mon Sep 17 00:00:00 2001 From: Mitchdev Date: Sun, 8 Dec 2024 02:00:17 +1300 Subject: [PATCH] Add clientOnlyMessages --- assets/chat/js/chat.js | 8 ++------ assets/chat/js/messages/MessageTypes.js | 13 ++++++++++++- assets/chat/js/messages/index.js | 2 +- assets/chat/js/window.js | 11 ++--------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/assets/chat/js/chat.js b/assets/chat/js/chat.js index 304fc271..a60de4b8 100644 --- a/assets/chat/js/chat.js +++ b/assets/chat/js/chat.js @@ -22,6 +22,7 @@ import { ChatMessage, ChatUserMessage, // eslint-disable-line no-unused-vars checkIfPinWasDismissed, + clientOnlyMessages, } from './messages'; import { ChatMenu, @@ -827,12 +828,7 @@ class Chat { // Hide the message if the user is ignored if ( - ![ - MessageTypes.UI, - MessageTypes.INFO, - MessageTypes.ERROR, - MessageTypes.STATUS, - ].includes(message.type) && + !clientOnlyMessages.includes(message.type) && this.ignored(message.user?.username, message.message) ) { message.ignore(); diff --git a/assets/chat/js/messages/MessageTypes.js b/assets/chat/js/messages/MessageTypes.js index b4b8a3a9..6a902c71 100644 --- a/assets/chat/js/messages/MessageTypes.js +++ b/assets/chat/js/messages/MessageTypes.js @@ -1,4 +1,4 @@ -export default { +const MessageTypes = { STATUS: 'STATUS', ERROR: 'ERROR', INFO: 'INFO', @@ -15,3 +15,14 @@ export default { DONATION: 'DONATION', DEATH: 'DEATH', }; + +const clientOnlyMessages = [ + MessageTypes.STATUS, + MessageTypes.ERROR, + MessageTypes.INFO, + MessageTypes.UI, +]; + +export default MessageTypes; + +export { clientOnlyMessages }; diff --git a/assets/chat/js/messages/index.js b/assets/chat/js/messages/index.js index e6dd08fb..684af454 100644 --- a/assets/chat/js/messages/index.js +++ b/assets/chat/js/messages/index.js @@ -1,5 +1,5 @@ export { default as MessageBuilder } from './MessageBuilder'; -export { default as MessageTypes } from './MessageTypes'; +export { default as MessageTypes, clientOnlyMessages } from './MessageTypes'; export { default as ChatMessage } from './ChatMessage'; export { default as ChatDonationMessage } from './ChatDonationMessage'; export { default as ChatEmoteMessage } from './ChatEmoteMessage'; diff --git a/assets/chat/js/window.js b/assets/chat/js/window.js index b76f7bcf..7c965b3b 100644 --- a/assets/chat/js/window.js +++ b/assets/chat/js/window.js @@ -2,7 +2,7 @@ import $ from 'jquery'; import { throttle } from 'throttle-debounce'; import ChatScrollPlugin from './scroll'; import EventEmitter from './emitter'; -import { MessageTypes } from './messages'; +import { clientOnlyMessages, MessageTypes } from './messages'; const tagcolors = [ 'green', @@ -152,14 +152,7 @@ class ChatWindow extends EventEmitter { const username = message.user?.username; - if ( - ![ - MessageTypes.UI, - MessageTypes.INFO, - MessageTypes.ERROR, - MessageTypes.STATUS, - ].includes(message.type) - ) { + if (!clientOnlyMessages.includes(message.type)) { message.ignore(chat.ignored(username, message.message)); }