/**
* @file
* @copyright 2020 Aleksej Komarov
* @license MIT
*/
import { toFixed } from 'common/math';
import { useLocalState } from 'tgui_ch/backend'; // CHOMPEdit - tgui_ch
import { useDispatch, useSelector } from 'common/redux';
import { Box, Button, ColorBox, Divider, Dropdown, Flex, Input, LabeledList, NumberInput, Section, Stack, Tabs, TextArea } from 'tgui_ch/components'; // CHOMPEdit - tgui_ch
import { ChatPageSettings } from '../chat';
import { rebuildChat, saveChatToDisk, purgeChatMessageArchive } from '../chat/actions';
import { THEMES } from '../themes';
import { changeSettingsTab, updateSettings, addHighlightSetting, removeHighlightSetting, updateHighlightSetting } from './actions';
import { SETTINGS_TABS, FONTS, MAX_HIGHLIGHT_SETTINGS } from './constants';
import { selectActiveTab, selectSettings, selectHighlightSettings, selectHighlightSettingById } from './selectors';
export const SettingsPanel = (props, context) => {
const activeTab = useSelector(context, selectActiveTab);
const dispatch = useDispatch(context);
return (
{SETTINGS_TABS.map((tab) => (
dispatch(
changeSettingsTab({
tabId: tab.id,
})
)
}>
{tab.name}
))}
{activeTab === 'general' && }
{activeTab === 'chatPage' && }
{activeTab === 'textHighlight' && }
);
};
export const SettingsGeneral = (props, context) => {
const { theme, fontFamily, fontSize, lineHeight } = useSelector(
context,
selectSettings
);
const dispatch = useDispatch(context);
const [freeFont, setFreeFont] = useLocalState(context, 'freeFont', false);
const [purgeConfirm, setPurgeConfirm] = useLocalState(
context,
'purgeConfirm',
0
);
return (
);
};
const TextHighlightSettings = (props, context) => {
const highlightSettings = useSelector(context, selectHighlightSettings);
const dispatch = useDispatch(context);
return (
{highlightSettings.map((id, i) => (
))}
{highlightSettings.length < MAX_HIGHLIGHT_SETTINGS && (
)}
Can freeze the chat for a while.
);
};
const TextHighlightSetting = (props, context) => {
const { id, ...rest } = props;
const highlightSettingById = useSelector(context, selectHighlightSettingById);
const dispatch = useDispatch(context);
const {
highlightColor,
highlightText,
highlightWholeMessage,
matchWord,
matchCase,
} = highlightSettingById[id];
return (
dispatch(
updateHighlightSetting({
id: id,
highlightWholeMessage: !highlightWholeMessage,
})
)
}
/>
dispatch(
updateHighlightSetting({
id: id,
matchWord: !matchWord,
})
)
}
/>
dispatch(
updateHighlightSetting({
id: id,
matchCase: !matchCase,
})
)
}
/>
dispatch(
updateHighlightSetting({
id: id,
highlightColor: value,
})
)
}
/>
);
};