mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Improve web interface console performance
Calculate the coloring for instance console messages once instead of every time the instance console is updated.
This commit is contained in:
1 parent
49eb966315
commit
5b74432ee3
1 file changed
+5
-3
@@ -106,11 +106,13 @@ function formatOutputColored(output, key) {
|
|||||||
|
|
||||||
function InstanceConsole(props) {
|
function InstanceConsole(props) {
|
||||||
let control = useContext(ControlContext);
|
let control = useContext(ControlContext);
|
||||||
let [lines, setLines] = useState([{ message: "<previous messages are not shown>" }]);
|
let [lines, setLines] = useState([<span key={0}>{"<previous messages are not shown>"}<br/></span>]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function outputHandler(output) {
|
function outputHandler(output) {
|
||||||
setLines(currentLines => currentLines.concat([output]));
|
setLines(currentLines => currentLines.concat(
|
||||||
|
[formatOutputColored(output, currentLines.length)]
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
control.onInstanceOutput(props.id, outputHandler);
|
control.onInstanceOutput(props.id, outputHandler);
|
||||||
@@ -121,7 +123,7 @@ function InstanceConsole(props) {
|
|||||||
|
|
||||||
return <>
|
return <>
|
||||||
<Paragraph code className="instance-console">
|
<Paragraph code className="instance-console">
|
||||||
{lines.map(formatOutputColored)}
|
{lines}
|
||||||
<div className="scroll-anchor" />
|
<div className="scroll-anchor" />
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</>;
|
</>;
|
||||||
|
|||||||
Reference in new issue
Block a user