mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-25 18:50:56 +02:00
UI: Fix (most) perf issues in Active Scripts (#498)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* React Component for rendering the Accordion elements for all servers
|
||||
* on which scripts are running
|
||||
*/
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState } from "react";
|
||||
|
||||
import { ServerAccordion } from "./ServerAccordion";
|
||||
|
||||
@@ -10,13 +10,11 @@ import TextField from "@mui/material/TextField";
|
||||
import List from "@mui/material/List";
|
||||
import TablePagination from "@mui/material/TablePagination";
|
||||
import { WorkerScript } from "../../Netscript/WorkerScript";
|
||||
import { WorkerScriptStartStopEventEmitter } from "../../Netscript/WorkerScriptStartStopEventEmitter";
|
||||
import { GetServer } from "../../Server/AllServers";
|
||||
import { BaseServer } from "../../Server/BaseServer";
|
||||
import { Settings } from "../../Settings/Settings";
|
||||
import { TablePaginationActionsAll } from "../React/TablePaginationActionsAll";
|
||||
import SearchIcon from "@mui/icons-material/Search";
|
||||
import { useRerender } from "../React/hooks";
|
||||
import { matchScriptPathUnanchored } from "../../utils/helpers/scriptKey";
|
||||
import lodash from "lodash";
|
||||
|
||||
@@ -38,13 +36,6 @@ export function ServerAccordions(props: IProps): React.ReactElement {
|
||||
const [filter, setFilter] = useState("");
|
||||
const [page, setPage] = useState(0);
|
||||
const [rowsPerPage, setRowsPerPage] = useState(Settings.ActiveScriptsServerPageSize);
|
||||
const rerenderHook = useRerender();
|
||||
let scheduledRerender = false;
|
||||
const rerender = () => {
|
||||
if (scheduledRerender) return;
|
||||
scheduledRerender = true;
|
||||
requestAnimationFrame(rerenderHook);
|
||||
};
|
||||
|
||||
const handleChangePage = (event: unknown, newPage: number): void => {
|
||||
setPage(newPage);
|
||||
@@ -92,8 +83,6 @@ export function ServerAccordions(props: IProps): React.ReactElement {
|
||||
return false;
|
||||
});
|
||||
|
||||
useEffect(() => WorkerScriptStartStopEventEmitter.subscribe(rerender));
|
||||
|
||||
return (
|
||||
<>
|
||||
<TextField
|
||||
|
||||
Reference in New Issue
Block a user