From 39cdde578f06995116ef54ec2006e1e9ab5014b6 Mon Sep 17 00:00:00 2001 From: xEsiah Date: Fri, 30 Oct 2026 21:01:55 +0100 Subject: [PATCH] fix: unified tab layout, full lightbox, global toasts --- src/App.tsx | 61 +++++++++++++++++++++++---------- src/components/MediaGallery.tsx | 44 ++++++++++++++---------- 2 files changed, 69 insertions(+), 36 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index d075a52..9d35ef7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,6 +11,13 @@ import { startSessionMonitor, } from "./lib/api"; +type ToastType = "info" | "success" | "error" | "warning"; + +interface Toast { + message: string; + type: ToastType; +} + export function App() { const [activeTab, setActiveTab] = useState<"live" | "media">("live"); const [isRecording, setIsRecording] = useState(false); @@ -19,7 +26,12 @@ export function App() { const [snapshots, setSnapshots] = useState([]); const [sessionExpired, setSessionExpired] = useState(false); const [streamKey, setStreamKey] = useState(0); - const [toast, setToast] = useState(null); + const [toast, setToast] = useState(null); + + const showToast = (message: string, type: ToastType = "info") => { + setToast({ message, type }); + setTimeout(() => setToast(null), 2500); + }; const { startRecording, @@ -48,7 +60,12 @@ export function App() { useEffect(() => { const off = onSessionChange((expired) => { setSessionExpired(expired); - if (!expired) setStreamKey((k) => k + 1); // recharge le flux vidéo après reconnexion + if (expired) { + showToast("Session expirée", "warning"); + } else { + showToast("Session reconnectée", "success"); + setStreamKey((k) => k + 1); // recharge le flux vidéo après reconnexion + } }); const stop = startSessionMonitor(); return () => { @@ -71,12 +88,10 @@ export function App() { if (!res.ok) throw new Error("Snapshot failed"); const data = await res.json(); setSnapshots((prev) => [data.filename, ...prev]); - setToast("Capture d'écran prise"); - setTimeout(() => setToast(null), 2000); + showToast("Capture d'écran prise", "success"); } catch (e) { console.error("Snapshot error:", e); - setToast("Erreur lors de la capture"); - setTimeout(() => setToast(null), 2000); + showToast("Erreur lors de la capture", "error"); } }; @@ -110,31 +125,41 @@ export function App() {
{toast && ( -
- {toast} +
+ {toast.message}
)} -