Hotfix: Popups no longer show up during infiltration (#847)

This commit is contained in:
Snarling
2023-10-04 09:52:04 -04:00
committed by GitHub
parent e22527e7b7
commit 74fe6af595
7 changed files with 42 additions and 51 deletions
+8 -10
View File
@@ -14,7 +14,7 @@ interface Alert {
}
let i = 0;
export function AlertManager(): React.ReactElement {
export function AlertManager({ hidden }: { hidden: boolean }): React.ReactElement {
const [alerts, setAlerts] = useState<Alert[]>([]);
useEffect(
() =>
@@ -49,6 +49,8 @@ export function AlertManager(): React.ReactElement {
return () => document.removeEventListener("keydown", handle);
}, []);
const alertMessage = alerts[0]?.text || "No alert to show";
function getMessageHash(text: string | JSX.Element): string {
if (typeof text === "string") return sha256(text);
return sha256(JSON.stringify(text.props));
@@ -61,14 +63,10 @@ export function AlertManager(): React.ReactElement {
}
return (
<>
{alerts.length > 0 && (
<Modal open={true} onClose={close}>
<Box overflow="scroll" sx={{ overflowWrap: "break-word", whiteSpace: "pre-line" }}>
<Typography component={"span"}>{alerts[0].text}</Typography>
</Box>
</Modal>
)}
</>
<Modal open={!hidden && alerts.length > 0} onClose={close}>
<Box overflow="scroll" sx={{ overflowWrap: "break-word", whiteSpace: "pre-line" }}>
<Typography component={"span"}>{alertMessage}</Typography>
</Box>
</Modal>
);
}