From 9a77b472410dbf9287c3fbb1263caade5d896420 Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Tue, 6 Aug 2024 03:40:16 +0700 Subject: [PATCH] MISC: Remove js-sha256 (#1278) --- package-lock.json | 6 ------ package.json | 1 - src/ui/React/AlertManager.tsx | 10 ++++++---- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3dad635c3..3578b5180 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,6 @@ "clsx": "^1.2.1", "date-fns": "^2.30.0", "escodegen": "^2.1.0", - "js-sha256": "^0.9.0", "jszip": "^3.10.1", "material-ui-color": "^1.2.0", "material-ui-popup-state": "^1.9.3", @@ -12636,11 +12635,6 @@ "integrity": "sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==", "dev": true }, - "node_modules/js-sha256": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", - "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", diff --git a/package.json b/package.json index 91566e323..2c0aa42f6 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "clsx": "^1.2.1", "date-fns": "^2.30.0", "escodegen": "^2.1.0", - "js-sha256": "^0.9.0", "jszip": "^3.10.1", "material-ui-color": "^1.2.0", "material-ui-popup-state": "^1.9.3", diff --git a/src/ui/React/AlertManager.tsx b/src/ui/React/AlertManager.tsx index c7c511202..bd62cc0ed 100644 --- a/src/ui/React/AlertManager.tsx +++ b/src/ui/React/AlertManager.tsx @@ -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 {