Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A possible FPS lag fix caused by chat spam. #27292

Merged
merged 6 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions tgui/packages/tgui-panel/chat/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ const updateMessageBadge = (message) => {
const foundBadge = node.querySelector('.Chat__badge');
const badge = foundBadge || document.createElement('div');
badge.textContent = times;
badge.className = classes(['Chat__badge', 'Chat__badge--animate']);
requestAnimationFrame(() => {
badge.className = 'Chat__badge';
});
badge.className = 'Chat__badge';
if (!foundBadge) {
node.appendChild(badge);
}
Expand Down Expand Up @@ -297,11 +294,7 @@ class ChatRenderer {
}
}

getCombinableMessage(predicate) {
const now = Date.now();
const len = this.visibleMessages.length;
const from = len - 1;
const to = Math.max(0, len - COMBINE_MAX_MESSAGES);
getCombinableMessage(predicate, now, from, to) {
for (let i = from; i >= to; i--) {
const message = this.visibleMessages[i];
// prettier-ignore
Expand Down Expand Up @@ -336,10 +329,14 @@ class ChatRenderer {
const fragment = document.createDocumentFragment();
const countByType = {};
let node;

const len = this.visibleMessages.length;
const from = len - 1;
const to = Math.max(0, len - COMBINE_MAX_MESSAGES);
for (let payload of batch) {
const message = createMessage(payload);
// Combine messages
const combinable = this.getCombinableMessage(message);
const combinable = this.getCombinableMessage(message, now, from, to);
if (combinable) {
combinable.times = (combinable.times || 1) + 1;
updateMessageBadge(combinable);
Expand Down
44 changes: 22 additions & 22 deletions tgui/public/tgui-panel.bundle.js

Large diffs are not rendered by default.