Skip to content

Commit

Permalink
Add clientOnlyMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchdev committed Dec 7, 2024
1 parent 7c82683 commit bd8cadf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
8 changes: 2 additions & 6 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ChatMessage,
ChatUserMessage, // eslint-disable-line no-unused-vars
checkIfPinWasDismissed,
clientOnlyMessages,
} from './messages';
import {
ChatMenu,
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 12 additions & 1 deletion assets/chat/js/messages/MessageTypes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
const MessageTypes = {
STATUS: 'STATUS',
ERROR: 'ERROR',
INFO: 'INFO',
Expand All @@ -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 };
2 changes: 1 addition & 1 deletion assets/chat/js/messages/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
11 changes: 2 additions & 9 deletions assets/chat/js/window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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));
}

Expand Down

0 comments on commit bd8cadf

Please sign in to comment.