From f17870926be9bfeab94adf946bd3f96a0bcf4e9b Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Fri, 26 Nov 2021 18:47:12 -0500 Subject: [PATCH] tail box close on soft reset --- src/Prestige.ts | 4 +++- src/ui/React/LogBoxManager.tsx | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Prestige.ts b/src/Prestige.ts index 48b5fbad9..2047f8326 100755 --- a/src/Prestige.ts +++ b/src/Prestige.ts @@ -28,6 +28,7 @@ import { dialogBoxCreate } from "./ui/React/DialogBox"; import { ProgramsSeen } from "./Programs/ui/ProgramsRoot"; import { InvitationsSeen } from "./Faction/ui/FactionsRoot"; +import { LogBoxClearEvents } from "./ui/React/LogBoxManager"; const BitNode8StartingMoney = 250e6; @@ -85,11 +86,12 @@ export function prestigeAugmentation(): void { } } - // Stop a Terminal action if there is onerror + // Stop a Terminal action if there is one. if (Terminal.action !== null) { Terminal.finishAction(Router, Player, true); } Terminal.clear(); + LogBoxClearEvents.emit(); // Re-initialize things - This will update any changes initFactions(); // Factions must be initialized before augmentations diff --git a/src/ui/React/LogBoxManager.tsx b/src/ui/React/LogBoxManager.tsx index 05a3beea4..7299d297d 100644 --- a/src/ui/React/LogBoxManager.tsx +++ b/src/ui/React/LogBoxManager.tsx @@ -19,6 +19,7 @@ import { Theme } from "@mui/material"; let layerCounter = 0; export const LogBoxEvents = new EventEmitter<[RunningScript]>(); +export const LogBoxClearEvents = new EventEmitter<[]>(); interface Log { id: string; @@ -46,6 +47,13 @@ export function LogBoxManager(): React.ReactElement { [], ); + useEffect(() => + LogBoxClearEvents.subscribe(() => { + logs = []; + rerender(); + }), + ); + function close(id: string): void { logs = logs.filter((l) => l.id !== id); rerender();