mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-29 23:17:28 +01:00
A few more settings (#15625)
This commit is contained in:
@@ -83,13 +83,13 @@ export const Panel = (props, context) => {
|
||||
<ChatPanel lineHeight={settings.lineHeight} />
|
||||
</Pane.Content>
|
||||
<Notifications>
|
||||
{game.connectionLostAt && (
|
||||
{settings.showReconnectWarning && game.connectionLostAt && (
|
||||
<Notifications.Item rightSlot={<ReconnectButton />}>
|
||||
You are either AFK, experiencing lag or the connection has
|
||||
closed.
|
||||
</Notifications.Item>
|
||||
)}
|
||||
{game.roundRestartedAt && (
|
||||
{settings.showReconnectWarning && game.roundRestartedAt && (
|
||||
<Notifications.Item>
|
||||
The connection has been closed because the server is
|
||||
restarting. Please wait while you automatically reconnect.
|
||||
|
||||
@@ -66,6 +66,31 @@ const loadChatFromStorage = async (store) => {
|
||||
}
|
||||
if (archivedMessages) {
|
||||
chatRenderer.archivedMessages = archivedMessages;
|
||||
|
||||
/* FIXME Implement this later on
|
||||
const settings = selectSettings(store.getState());
|
||||
const filteredMessages = [];
|
||||
|
||||
// Checks if the setting is actually set or set to -1 (infinite)
|
||||
// Otherwise make it grow infinitely
|
||||
if (settings.logRetainDays || settings.logRetainDays === -1) {
|
||||
const limit = new Date();
|
||||
limit.setDate(limit.getMinutes() - settings.logRetainDays);
|
||||
|
||||
for (let message of archivedMessages) {
|
||||
const timestamp = new Date(message.createdAt);
|
||||
timestamp.setDate(timestamp.getMinutes() - settings.logRetainDays);
|
||||
|
||||
if (timestamp.getDate() < limit.getDate()) {
|
||||
filteredMessages.push(message);
|
||||
}
|
||||
}
|
||||
|
||||
archivedMessages.length = 0;
|
||||
}
|
||||
|
||||
chatRenderer.archivedMessages = filteredMessages;
|
||||
*/
|
||||
}
|
||||
store.dispatch(loadChat(state));
|
||||
};
|
||||
@@ -179,7 +204,8 @@ export const chatMiddleware = (store) => {
|
||||
return next(action);
|
||||
}
|
||||
if (type === saveChatToDisk.type) {
|
||||
chatRenderer.saveToDisk();
|
||||
const settings = selectSettings(store.getState());
|
||||
chatRenderer.saveToDisk(settings.logLineCount);
|
||||
return;
|
||||
}
|
||||
if (type === purgeChatMessageArchive.type) {
|
||||
|
||||
@@ -552,7 +552,7 @@ class ChatRenderer {
|
||||
});
|
||||
}
|
||||
|
||||
saveToDisk() {
|
||||
saveToDisk(logLineCount) {
|
||||
// Allow only on IE11
|
||||
if (Byond.IS_LTE_IE10) {
|
||||
return;
|
||||
@@ -572,8 +572,16 @@ class ChatRenderer {
|
||||
cssText += 'body, html { background-color: #141414 }\n';
|
||||
// Compile chat log as HTML text
|
||||
let messagesHtml = '';
|
||||
|
||||
let tmpMsgArray = [];
|
||||
if (logLineCount > 0) {
|
||||
tmpMsgArray = this.archivedMessages.slice(-logLineCount);
|
||||
} else {
|
||||
tmpMsgArray = this.archivedMessages;
|
||||
}
|
||||
|
||||
// for (let message of this.visibleMessages) { // TODO: Actually having a better message archiving maybe for exports?
|
||||
for (let message of this.archivedMessages) {
|
||||
for (let message of tmpMsgArray) {
|
||||
// if (message.node) {
|
||||
// messagesHtml += message.node.outerHTML + '\n';
|
||||
// }
|
||||
|
||||
@@ -42,6 +42,7 @@ export const SettingsPanel = (props, context) => {
|
||||
</Stack.Item>
|
||||
<Stack.Item grow={1} basis={0}>
|
||||
{activeTab === 'general' && <SettingsGeneral />}
|
||||
{activeTab === 'export' && <ExportTab />}
|
||||
{activeTab === 'chatPage' && <ChatPageSettings />}
|
||||
{activeTab === 'textHighlight' && <TextHighlightSettings />}
|
||||
</Stack.Item>
|
||||
@@ -50,17 +51,10 @@ export const SettingsPanel = (props, context) => {
|
||||
};
|
||||
|
||||
export const SettingsGeneral = (props, context) => {
|
||||
const { theme, fontFamily, fontSize, lineHeight } = useSelector(
|
||||
context,
|
||||
selectSettings
|
||||
);
|
||||
const { theme, fontFamily, fontSize, lineHeight, showReconnectWarning } =
|
||||
useSelector(context, selectSettings);
|
||||
const dispatch = useDispatch(context);
|
||||
const [freeFont, setFreeFont] = useLocalState(context, 'freeFont', false);
|
||||
const [purgeConfirm, setPurgeConfirm] = useLocalState(
|
||||
context,
|
||||
'purgeConfirm',
|
||||
0
|
||||
);
|
||||
return (
|
||||
<Section>
|
||||
<LabeledList>
|
||||
@@ -155,6 +149,67 @@ export const SettingsGeneral = (props, context) => {
|
||||
}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Enable disconnection/afk warning">
|
||||
<Button.Checkbox
|
||||
checked={showReconnectWarning}
|
||||
content=""
|
||||
tooltip="Unchecking this will disable the red afk/reconnection warning bar at the bottom of the chat."
|
||||
mr="5px"
|
||||
onClick={() =>
|
||||
dispatch(
|
||||
updateSettings({
|
||||
showReconnectWarning: !showReconnectWarning,
|
||||
})
|
||||
)
|
||||
}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
export const ExportTab = (props, context) => {
|
||||
const dispatch = useDispatch(context);
|
||||
const { logRetainDays, logLineCount } = useSelector(context, selectSettings);
|
||||
const [purgeConfirm, setPurgeConfirm] = useLocalState(
|
||||
context,
|
||||
'purgeConfirm',
|
||||
0
|
||||
);
|
||||
return (
|
||||
<Section>
|
||||
<LabeledList>
|
||||
{/* FIXME: Implement this later on
|
||||
<LabeledList.Item label="Days to retain logs (-1 = inf.)">
|
||||
<Input
|
||||
width="5em"
|
||||
monospace
|
||||
value={logRetainDays}
|
||||
onInput={(e, value) =>
|
||||
dispatch(
|
||||
updateSettings({
|
||||
logRetainDays: value,
|
||||
})
|
||||
)
|
||||
}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
*/}
|
||||
<LabeledList.Item label="Amount of lines to export (-1 = inf.)">
|
||||
<Input
|
||||
width="5em"
|
||||
monospace
|
||||
value={logLineCount}
|
||||
onInput={(e, value) =>
|
||||
dispatch(
|
||||
updateSettings({
|
||||
logLineCount: value,
|
||||
})
|
||||
)
|
||||
}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
<Divider />
|
||||
<Button icon="save" onClick={() => dispatch(saveChatToDisk())}>
|
||||
|
||||
@@ -9,7 +9,10 @@ export const SETTINGS_TABS = [
|
||||
id: 'general',
|
||||
name: 'General',
|
||||
},
|
||||
|
||||
{
|
||||
id: 'export',
|
||||
name: 'Export',
|
||||
},
|
||||
{
|
||||
id: 'textHighlight',
|
||||
name: 'Text Highlights',
|
||||
|
||||
@@ -29,6 +29,9 @@ const initialState = {
|
||||
visible: false,
|
||||
activeTab: SETTINGS_TABS[0].id,
|
||||
},
|
||||
showReconnectWarning: true,
|
||||
logRetainDays: -1,
|
||||
logLineCount: -1,
|
||||
};
|
||||
|
||||
export const settingsReducer = (state = initialState, action) => {
|
||||
|
||||
+126
-126
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user