MISC: Remove js-sha256 (#1278)

This commit is contained in:
catloversg
2024-08-06 03:40:16 +07:00
committed by GitHub
parent eeac3f7dd1
commit 9a77b47241
3 changed files with 6 additions and 11 deletions

View File

@@ -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 { cyrb53 } from "../../utils/StringHelperFunctions";
export const AlertEvents = new EventEmitter<[string | JSX.Element]>();
@@ -17,8 +17,8 @@ export function AlertManager({ hidden }: { hidden: boolean }): React.ReactElemen
useEffect(
() =>
AlertEvents.subscribe((text: string | JSX.Element) => {
const hash = getMessageHash(text);
setAlerts((old) => {
const hash = getMessageHash(text);
if (old.some((a) => a.hash === hash)) {
return old;
}
@@ -47,8 +47,10 @@ export function AlertManager({ hidden }: { hidden: boolean }): React.ReactElemen
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));
if (typeof text === "string") {
return cyrb53(text);
}
return cyrb53(JSON.stringify(text.props));
}
function close(): void {