import { useState } from 'react'; import { useDispatch, useSelector } from 'tgui/backend'; import { Box, Button, Collapsible, Divider, Dropdown, LabeledList, NumberInput, Section, Stack, } from 'tgui-core/components'; import { toFixed } from 'tgui-core/math'; import { purgeChatMessageArchive, saveChatToDisk } from '../../chat/actions'; import { MESSAGE_TYPES } from '../../chat/constants'; import { useGame } from '../../game'; import { updateSettings, updateToggle } from '../actions'; import { selectSettings } from '../selectors'; export const ExportTab = (props) => { const dispatch = useDispatch(); const game = useGame(); const { storedRounds, exportStart, exportEnd, logRetainRounds, logEnable, logLineCount, logLimit, totalStoredMessages, storedTypes, } = useSelector(selectSettings); const [purgeButtonText, setPurgeButtonText] = useState( 'Purge message archive', ); return (
{!game.databaseBackendEnabled && (logEnable ? ( { dispatch( updateSettings({ logEnable: false, }), ); }} > Disable logging ) : ( ))} Round ID:  {game.roundId ? game.roundId : 'ERROR'} DB Chatlogging:  {game.databaseBackendEnabled ? 'Enabled' : 'Disabled'} {logEnable && !game.databaseBackendEnabled && ( <> toFixed(value)} onDrag={(value) => dispatch( updateSettings({ logRetainRounds: value, }), ) } />   {logRetainRounds > 3 && ( Warning, might crash! )} toFixed(value)} onDrag={(value) => dispatch( updateSettings({ logLimit: value, }), ) } />   {logLimit > 0 && ( 10000 ? 'red' : 'label'} > {logLimit > 15000 ? 'Warning, might crash! Takes priority above round retention.' : 'Takes priority above round retention.'} )}
{MESSAGE_TYPES.map((typeDef) => ( dispatch( updateToggle({ type: typeDef.type, }), ) } > {typeDef.name} ))}
)} {game.databaseBackendEnabled ? ( <> dispatch( updateSettings({ exportStart: value, }), ) } options={game.databaseStoredRounds} selected={exportStart} /> dispatch( updateSettings({ exportEnd: value, }), ) } options={game.databaseStoredRounds} selected={exportEnd} /> ) : ( <> toFixed(value)} onDrag={(value) => dispatch( updateSettings({ exportStart: value, }), ) } /> toFixed(value)} onDrag={(value) => dispatch( updateSettings({ exportEnd: value, }), ) } /> )}  Stored Rounds:  {game.databaseBackendEnabled ? game.databaseStoredRounds.length - 1 : storedRounds} toFixed(value)} onDrag={(value) => dispatch( updateSettings({ logLineCount: value, }), ) } /> {!game.databaseBackendEnabled && ( {totalStoredMessages} )} {!game.databaseBackendEnabled && ( { dispatch(purgeChatMessageArchive()); setPurgeButtonText('Purged!'); setTimeout(() => { setPurgeButtonText('Purge message archive'); }, 1000); }} > {purgeButtonText} )}
); };