Skip to content

[516] Reduces stuttering issues for 516 users #29078

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

Merged
merged 6 commits into from
May 1, 2025
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
4 changes: 2 additions & 2 deletions tgui/packages/tgui-panel/chat/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

export const MAX_VISIBLE_MESSAGES = 2500;
export const MAX_PERSISTED_MESSAGES = 1000;
export const MESSAGE_SAVE_INTERVAL = 10000;
export const MAX_PERSISTED_MESSAGES = 500;
export const MESSAGE_SAVE_INTERVAL = 60000;
export const MESSAGE_PRUNE_INTERVAL = 60000;
export const COMBINE_MAX_TIME_WINDOW = 5000;
export const COMBINE_MAX_MESSAGES = 5;
Expand Down
13 changes: 13 additions & 0 deletions tgui/packages/tgui-panel/chat/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ import { selectChat, selectCurrentChatPage } from './selectors';
const blacklisted_tags = ['a', 'iframe', 'link', 'video'];

const saveChatToStorage = async (store) => {
// Early return if chat saving is disabled
const chatSavingEnabled = await storage.get('chat-saving-enabled');
if (chatSavingEnabled === false) {
return;
}

const state = selectChat(store.getState());
const fromIndex = Math.max(0, chatRenderer.messages.length - MAX_PERSISTED_MESSAGES);
const messages = chatRenderer.messages.slice(fromIndex).map((message) => serializeMessage(message));
Expand All @@ -45,6 +51,13 @@ const saveChatToStorage = async (store) => {
};

const loadChatFromStorage = async (store) => {
// Early return if chat saving is disabled
const chatSavingEnabled = await storage.get('chat-saving-enabled');
if (chatSavingEnabled === false) {
store.dispatch(loadChat());
return;
}

const [state, messages] = await Promise.all([storage.get('chat-state'), storage.get('chat-messages')]);
// Discard incompatible versions
if (state && state.version <= 4) {
Expand Down
22 changes: 21 additions & 1 deletion tgui/packages/tgui-panel/settings/SettingsPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
import { SETTINGS_TABS, FONTS, MAX_HIGHLIGHT_SETTINGS } from './constants';
import { selectActiveTab, selectSettings, selectHighlightSettings, selectHighlightSettingById } from './selectors';
import { SettingsStatPanel } from './SettingsStatPanel';
import { storage } from 'common/storage';

export const SettingsPanel = (props, context) => {
const activeTab = useSelector(context, selectActiveTab);
Expand Down Expand Up @@ -73,9 +74,20 @@ export const SettingsPanel = (props, context) => {
};

export const SettingsGeneral = (props, context) => {
const { theme, fontFamily, fontSize, lineHeight } = useSelector(context, selectSettings);
const { theme, fontFamily, fontSize, lineHeight, chatSaving } = useSelector(context, selectSettings);
const dispatch = useDispatch(context);
const [freeFont, setFreeFont] = useLocalState(context, 'freeFont', false);

const updateChatSaving = (value) => {
const boolValue = value === true;
dispatch(
updateSettings({
chatSaving: boolValue,
})
);
storage.set('chat-saving-enabled', boolValue);
};

return (
<Section fill>
<Stack fill vertical>
Expand Down Expand Up @@ -194,6 +206,14 @@ export const SettingsGeneral = (props, context) => {
</LabeledList>
<Divider />
<Stack>
<Stack.Item>
<Button.Checkbox
checked={chatSaving === true}
content="Persistent Chat"
tooltip="Enable chat persistence"
onClick={() => updateChatSaving(!chatSaving)}
/>
</Stack.Item>
<Stack.Item grow>
<Button
content="Save chat log"
Expand Down
4 changes: 4 additions & 0 deletions tgui/packages/tgui-panel/settings/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from './actions';
import { createDefaultHighlightSetting } from './model';
import { SETTINGS_TABS, FONTS, MAX_HIGHLIGHT_SETTINGS } from './constants';
import { storage } from 'common/storage';

const defaultHighlightSetting = createDefaultHighlightSetting();

Expand Down Expand Up @@ -44,6 +45,9 @@ const initialState = {
statFontFamily: FONTS[0],
statTabsStyle: 'default',
// End of Stat Panel settings

// Chat persistence setting - default is false, but use stored value if available
chatSaving: storage.get('chat-saving-enabled') === true,
};

export const settingsReducer = (state = initialState, action) => {
Expand Down
206 changes: 103 additions & 103 deletions tgui/public/tgui-panel.bundle.js

Large diffs are not rendered by default.