UI: Fix (most) perf issues in Active Scripts (#498)

This commit is contained in:
David Walker
2023-04-30 16:31:29 -07:00
committed by GitHub
parent 2f46831ad1
commit 8b7166e4ed
6 changed files with 11 additions and 38 deletions
+1 -12
View File
@@ -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