fix a few bugs

This commit is contained in:
Olivier Gagnon 2021-11-13 19:50:39 -05:00
parent 22048d6ba6
commit 82314762d5
4 changed files with 17 additions and 15 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -21,28 +21,30 @@ interface Log {
script: RunningScript;
}
let logs: Log[] = [];
export function LogBoxManager(): React.ReactElement {
const [logs, setLogs] = useState<Log[]>([]);
const setRerender = useState(true)[1];
function rerender(): void {
setRerender((o) => !o);
}
useEffect(
() =>
LogBoxEvents.subscribe((script: RunningScript) => {
const id = script.server + "-" + script.filename + script.args.map((x: any): string => `${x}`).join("-");
if (logs.find((l) => l.id === id)) return;
setLogs((old) => {
return [
...old,
{
id: id,
script: script,
},
];
logs.push({
id: id,
script: script,
});
rerender();
}),
[],
);
function close(id: string): void {
setLogs((old) => old.filter((l) => l.id !== id));
logs = logs.filter((l) => l.id !== id);
rerender();
}
return (