diff --git a/tgui/packages/tgui-panel/chat/middleware.js b/tgui/packages/tgui-panel/chat/middleware.js index 3629b5d26e..71b351e539 100644 --- a/tgui/packages/tgui-panel/chat/middleware.js +++ b/tgui/packages/tgui-panel/chat/middleware.js @@ -166,6 +166,7 @@ export const chatMiddleware = (store) => { settings.storedTypes, game.roundId, settings.prependTimestamps, + settings.hideImportantInAdminTab, ); // Load the chat once settings are loaded if (!initialized && settings.initialized) { diff --git a/tgui/packages/tgui-panel/chat/model.js b/tgui/packages/tgui-panel/chat/model.js index 21fa2bc2b4..218d958bfd 100644 --- a/tgui/packages/tgui-panel/chat/model.js +++ b/tgui/packages/tgui-panel/chat/model.js @@ -11,6 +11,35 @@ import { MESSAGE_TYPE_INTERNAL, MESSAGE_TYPES } from './constants'; export const canPageAcceptType = (page, type) => type.startsWith(MESSAGE_TYPE_INTERNAL) || page.acceptedTypes[type]; +export const typeIsImportant = (type) => { + let isImportant = false; + for (let typeDef of MESSAGE_TYPES) { + if (typeDef.type === type && !!typeDef.important) { + isImportant = true; + break; + } + } + return isImportant; +}; + +export const adminPageOnly = (page) => { + let adminTab = true; + let checked = 0; + for (let typeDef of MESSAGE_TYPES) { + if ( + page.acceptedTypes[typeDef.type] && + !(!!typeDef.important || !!typeDef.admin) + ) { + adminTab = false; + break; + } + if (page.acceptedTypes[typeDef.type] && !typeDef.important) { + checked++; + } + } + return checked > 0 && adminTab; +}; + export const canStoreType = (storedTypes, type) => storedTypes[type]; export const createPage = (obj) => { diff --git a/tgui/packages/tgui-panel/chat/renderer.jsx b/tgui/packages/tgui-panel/chat/renderer.jsx index d1050012c6..c04025bc4f 100644 --- a/tgui/packages/tgui-panel/chat/renderer.jsx +++ b/tgui/packages/tgui-panel/chat/renderer.jsx @@ -20,11 +20,13 @@ import { MESSAGE_TYPES, } from './constants'; import { + adminPageOnly, canPageAcceptType, canStoreType, createMessage, isSameMessage, serializeMessage, + typeIsImportant, } from './model'; import { highlightNode, linkifyNode } from './replaceInTextNode'; @@ -155,6 +157,7 @@ class ChatRenderer { this.logEnable = true; this.roundId = null; this.storedTypes = {}; + this.hideImportantInAdminTab = false; // Scroll handler /** @type {HTMLElement} */ this.scrollNode = null; @@ -366,6 +369,30 @@ class ChatRenderer { this.scrollNode.scrollTop = this.scrollNode.scrollHeight; } + setVisualChatLimits( + visibleMessageLimit, + combineMessageLimit, + combineIntervalLimit, + exportLimit, + logEnable, + logLimit, + storedTypes, + roundId, + prependTimestamps, + hideImportantInAdminTab, + ) { + this.visibleMessageLimit = visibleMessageLimit; + this.combineMessageLimit = combineMessageLimit; + this.combineIntervalLimit = combineIntervalLimit; + this.exportLimit = exportLimit; + this.logEnable = logEnable; + this.logLimit = logLimit; + this.storedTypes = storedTypes; + this.roundId = roundId; + this.prependTimestamps = prependTimestamps; + this.hideImportantInAdminTab = hideImportantInAdminTab; + } + changePage(page) { if (!this.isReady()) { this.page = page; @@ -380,7 +407,14 @@ class ChatRenderer { const fragment = document.createDocumentFragment(); let node; for (let message of this.messages) { - if (canPageAcceptType(page, message.type)) { + if ( + canPageAcceptType(page, message.type) && + !( + adminPageOnly(page) && + typeIsImportant(message.type) && + this.hideImportantInAdminTab + ) + ) { node = message.node; fragment.appendChild(node); this.visibleMessages.push(message); @@ -392,28 +426,6 @@ class ChatRenderer { } } - setVisualChatLimits( - visibleMessageLimit, - combineMessageLimit, - combineIntervalLimit, - exportLimit, - logEnable, - logLimit, - storedTypes, - roundId, - prependTimestamps, - ) { - this.visibleMessageLimit = visibleMessageLimit; - this.combineMessageLimit = combineMessageLimit; - this.combineIntervalLimit = combineIntervalLimit; - this.exportLimit = exportLimit; - this.logEnable = logEnable; - this.logLimit = logLimit; - this.storedTypes = storedTypes; - this.roundId = roundId; - this.prependTimestamps = prependTimestamps; - } - getCombinableMessage(predicate) { const now = Date.now(); const len = this.visibleMessages.length; @@ -619,7 +631,14 @@ class ChatRenderer { } this.archivedMessages.push(serializeMessage(message, true)); // TODO: Actually having a better message archiving maybe for exports? } - if (canPageAcceptType(this.page, message.type)) { + if ( + canPageAcceptType(this.page, message.type) && + !( + adminPageOnly(this.page) && + typeIsImportant(message.type) && + this.hideImportantInAdminTab + ) + ) { fragment.appendChild(node); this.visibleMessages.push(message); } diff --git a/tgui/packages/tgui-panel/settings/SettingsPanel.jsx b/tgui/packages/tgui-panel/settings/SettingsPanel.jsx index 8d9d8ea616..9109000d6a 100644 --- a/tgui/packages/tgui-panel/settings/SettingsPanel.jsx +++ b/tgui/packages/tgui-panel/settings/SettingsPanel.jsx @@ -81,6 +81,7 @@ export const SettingsPanel = (props) => { {activeTab === 'export' && } {activeTab === 'chatPage' && } {activeTab === 'textHighlight' && } + {activeTab === 'adminSettings' && } ); @@ -804,3 +805,29 @@ const TextHighlightSetting = (props) => { ); }; + +export const AdminSettings = (props) => { + const dispatch = useDispatch(); + const { hideImportantInAdminTab } = useSelector(selectSettings); + return ( +
+ + + + dispatch( + updateSettings({ + hideImportantInAdminTab: !hideImportantInAdminTab, + }), + ) + } + /> + + +
+ ); +}; diff --git a/tgui/packages/tgui-panel/settings/constants.ts b/tgui/packages/tgui-panel/settings/constants.ts index 671b1137e9..8be68f3d2c 100644 --- a/tgui/packages/tgui-panel/settings/constants.ts +++ b/tgui/packages/tgui-panel/settings/constants.ts @@ -9,6 +9,10 @@ export const SETTINGS_TABS = [ id: 'general', name: 'General', }, + { + id: 'adminSettings', + name: 'Admin', + }, { id: 'limits', name: 'Visual Limits', diff --git a/tgui/packages/tgui-panel/settings/reducer.js b/tgui/packages/tgui-panel/settings/reducer.js index 2b2f44e43b..90dc571f4e 100644 --- a/tgui/packages/tgui-panel/settings/reducer.js +++ b/tgui/packages/tgui-panel/settings/reducer.js @@ -58,6 +58,7 @@ const initialState = { lastId: null, initialized: false, storedTypes: {}, + hideImportantInAdminTab: false, }; export const settingsReducer = (state = initialState, action) => {