mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 15:43:49 +01:00
fix react error
This commit is contained in:
parent
edb347e566
commit
10f7d0ebbc
@ -48,6 +48,7 @@ import { calculateAchievements } from "./Achievements/Achievements";
|
||||
|
||||
import React from "react";
|
||||
import { setupUncaughtPromiseHandler } from "./UncaughtPromiseHandler";
|
||||
import { Typography } from "@mui/material";
|
||||
|
||||
const Engine: {
|
||||
_lastUpdate: number;
|
||||
@ -401,11 +402,21 @@ const Engine: {
|
||||
() =>
|
||||
AlertEvents.emit(
|
||||
<>
|
||||
Offline for {timeOfflineString}. While you were offline:
|
||||
<Typography>Offline for {timeOfflineString}. While you were offline:</Typography>
|
||||
<ul>
|
||||
<li>Your scripts generated{" "} <Money money={offlineHackingIncome} /></li>
|
||||
<li>Your Hacknet Nodes generated {hacknetProdInfo}</li>
|
||||
<li>You gained{" "} <Reputation reputation={offlineReputation} /> reputation divided amongst your factions</li>
|
||||
<li>
|
||||
<Typography>
|
||||
Your scripts generated <Money money={offlineHackingIncome} />
|
||||
</Typography>
|
||||
</li>
|
||||
<li>
|
||||
<Typography>Your Hacknet Nodes generated {hacknetProdInfo}</Typography>
|
||||
</li>
|
||||
<li>
|
||||
<Typography>
|
||||
You gained <Reputation reputation={offlineReputation} /> reputation divided amongst your factions
|
||||
</Typography>
|
||||
</li>
|
||||
</ul>
|
||||
</>,
|
||||
),
|
||||
|
@ -3,7 +3,7 @@ import { EventEmitter } from "../../utils/EventEmitter";
|
||||
import { Modal } from "./Modal";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import Box from "@mui/material/Box";
|
||||
import {sha256} from "js-sha256";
|
||||
import { sha256 } from "js-sha256";
|
||||
|
||||
export const AlertEvents = new EventEmitter<[string | JSX.Element]>();
|
||||
|
||||
@ -23,8 +23,8 @@ export function AlertManager(): React.ReactElement {
|
||||
i++;
|
||||
setAlerts((old) => {
|
||||
const hash = getMessageHash(text);
|
||||
if (old.some(a => a.hash === hash)) {
|
||||
console.log('Duplicate message');
|
||||
if (old.some((a) => a.hash === hash)) {
|
||||
console.log("Duplicate message");
|
||||
return old;
|
||||
}
|
||||
return [
|
||||
@ -51,7 +51,7 @@ export function AlertManager(): React.ReactElement {
|
||||
}, []);
|
||||
|
||||
function getMessageHash(text: string | JSX.Element): string {
|
||||
if (typeof text === 'string') return sha256(text);
|
||||
if (typeof text === "string") return sha256(text);
|
||||
return sha256(JSON.stringify(text.props));
|
||||
}
|
||||
|
||||
@ -66,7 +66,8 @@ export function AlertManager(): React.ReactElement {
|
||||
{alerts.length > 0 && (
|
||||
<Modal open={true} onClose={close}>
|
||||
<Box overflow="scroll" sx={{ overflowWrap: "break-word", whiteSpace: "pre-line" }}>
|
||||
<Typography>{alerts[0].text}</Typography>
|
||||
{typeof alerts[0].text === "string" && <Typography>{alerts[0].text}</Typography>}
|
||||
{typeof alerts[0].text !== "string" && alerts[0].text}
|
||||
</Box>
|
||||
</Modal>
|
||||
)}
|
||||
|
Loading…
Reference in New Issue
Block a user