UI: Prevent terminal scroll on progress bar update (fix #94) (#544)

This commit is contained in:
bezrodnov 2023-05-29 20:59:17 +02:00 committed by GitHub
parent becca87224
commit 606b4bee95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 11 deletions

@ -102,7 +102,6 @@ export class Terminal {
if (this.action === null) return;
this.action.timeLeft -= (CONSTANTS.MilliPerCycle * cycles) / 1000;
if (this.action.timeLeft < 0.01) this.finishAction(false);
TerminalEvents.emit();
}
append(item: Output | Link | RawOutput): void {

@ -0,0 +1,11 @@
import React from "react";
import Typography from "@mui/material/Typography";
import { useRerender } from "../../ui/React/hooks";
import { Terminal } from "../../Terminal";
export function TerminalActionTimer(): React.ReactElement {
useRerender(200);
return <Typography color="primary">{Terminal.action && Terminal.getProgressText()}</Typography>;
}

@ -7,6 +7,8 @@ import { Theme } from "@mui/material/styles";
import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
import Box from "@mui/material/Box";
import _ from "lodash";
import { Output, Link, RawOutput } from "../OutputTypes";
import { Terminal } from "../../Terminal";
import { TerminalInput } from "./TerminalInput";
@ -14,17 +16,9 @@ import { TerminalEvents, TerminalClearEvents } from "../TerminalEvents";
import { BitFlumeModal } from "../../BitNode/ui/BitFlumeModal";
import { CodingContractModal } from "../../ui/React/CodingContractModal";
import _ from "lodash";
import { ANSIITypography } from "../../ui/React/ANSIITypography";
import { useRerender } from "../../ui/React/hooks";
function ActionTimer(): React.ReactElement {
return (
<Typography color={"primary"} paragraph={false}>
{Terminal.getProgressText()}
</Typography>
);
}
import { TerminalActionTimer } from "./TerminalActionTimer";
const useStyles = makeStyles((theme: Theme) =>
createStyles({
@ -116,7 +110,7 @@ export function TerminalRoot(): React.ReactElement {
{Terminal.action !== null && (
<ListItem classes={{ root: classes.nopadding }}>
<ActionTimer />{" "}
<TerminalActionTimer />{" "}
</ListItem>
)}
</List>