Fix for Information exposure through an exception #72

This commit is contained in:
maziggy
2026-02-03 13:48:44 +01:00
parent b05f376e70
commit ababe4e3ed
3 changed files with 22 additions and 4 deletions
+20 -2
View File
@@ -1,4 +1,4 @@
import { createContext, useContext, useState, useCallback, type ReactNode } from 'react';
import { createContext, useContext, useState, useCallback, useRef, useEffect, type ReactNode } from 'react';
import { CheckCircle, XCircle, AlertCircle, Info, X, Loader2 } from 'lucide-react';
type ToastType = 'success' | 'error' | 'warning' | 'info' | 'loading';
@@ -44,15 +44,27 @@ const bgColors = {
export function ToastProvider({ children }: { children: ReactNode }) {
const [toasts, setToasts] = useState<Toast[]>([]);
const timeoutRefs = useRef<Map<string, ReturnType<typeof setTimeout>>>(new Map());
// Clean up all timeouts on unmount
useEffect(() => {
const timeouts = timeoutRefs.current;
return () => {
timeouts.forEach((timeout) => clearTimeout(timeout));
timeouts.clear();
};
}, []);
const showToast = useCallback((message: string, type: ToastType = 'success') => {
const id = Math.random().toString(36).substr(2, 9);
setToasts((prev) => [...prev, { id, message, type }]);
// Auto-dismiss after 3 seconds
setTimeout(() => {
const timeout = setTimeout(() => {
setToasts((prev) => prev.filter((t) => t.id !== id));
timeoutRefs.current.delete(id);
}, 3000);
timeoutRefs.current.set(id, timeout);
}, []);
const showPersistentToast = useCallback((id: string, message: string, type: ToastType = 'info') => {
@@ -67,6 +79,12 @@ export function ToastProvider({ children }: { children: ReactNode }) {
}, []);
const dismissToast = useCallback((id: string) => {
// Clear any pending auto-dismiss timeout
const timeout = timeoutRefs.current.get(id);
if (timeout) {
clearTimeout(timeout);
timeoutRefs.current.delete(id);
}
setToasts((prev) => prev.filter((t) => t.id !== id));
}, []);
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -23,7 +23,7 @@
<!-- Splash screens for iOS -->
<link rel="apple-touch-startup-image" href="/img/android-chrome-512x512.png" />
<script type="module" crossorigin src="/assets/index-CKG31ANB.js"></script>
<script type="module" crossorigin src="/assets/index-B5vyvTs3.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-DME4t7XG.css">
</head>
<body>