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

Ports chat lag fixes from paradise #225

Merged
merged 1 commit into from
Feb 7, 2025
Merged
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
20 changes: 14 additions & 6 deletions tgui/packages/tgui-panel/chat/renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { EventEmitter } from 'common/events';
import { classes } from 'common/react';
/* import { classes } from 'common/react';*/ // IRIS REMOVAL
import { createRoot } from 'react-dom/client';
import { Tooltip } from 'tgui/components';
import { createLogger } from 'tgui/logging';
Expand Down Expand Up @@ -107,10 +107,11 @@ 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']);
/* badge.className = classes(['Chat__badge', 'Chat__badge--animate']);
requestAnimationFrame(() => {
badge.className = 'Chat__badge';
});
});*/
badge.className = 'Chat__badge'; // IRIS EDIT
if (!foundBadge) {
node.appendChild(badge);
}
Expand Down Expand Up @@ -311,11 +312,12 @@ class ChatRenderer {
}
}

getCombinableMessage(predicate) {
/* getCombinableMessage(predicate) {
const now = Date.now();
const len = this.visibleMessages.length;
const from = len - 1;
const to = Math.max(0, len - COMBINE_MAX_MESSAGES);
const to = Math.max(0, len - COMBINE_MAX_MESSAGES);*/ // IRIS EDIT
getCombinableMessage(predicate, now, from, to) {
for (let i = from; i >= to; i--) {
const message = this.visibleMessages[i];

Expand Down Expand Up @@ -349,10 +351,16 @@ class ChatRenderer {
const fragment = document.createDocumentFragment();
const countByType = {};
let node;

// IRIS EDIT
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);
// IRIS EDIT END
if (combinable) {
combinable.times = (combinable.times || 1) + 1;
updateMessageBadge(combinable);
Expand Down
Loading