diff --git a/web/src/App.tsx b/web/src/App.tsx index 2773a39..c9f9553 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -100,6 +100,23 @@ export default function App() { return () => window.removeEventListener('scroll', onScroll); }, []); + // Live-Update für totalPlays Counter + useEffect(() => { + const updateTotalPlays = async () => { + try { + const h = await fetch('/api/health').then(r => r.json()).catch(() => null); + if (h && typeof h.totalPlays === 'number') setTotalPlays(h.totalPlays); + } catch {} + }; + + // Sofort beim Start laden + updateTotalPlays(); + + // Alle 5 Sekunden aktualisieren + const interval = setInterval(updateTotalPlays, 5000); + return () => clearInterval(interval); + }, []); + useEffect(() => { (async () => { if (selected) { @@ -166,11 +183,11 @@ export default function App() {
Geladene Sounds
+Sounds
{total}
Insgesamt abgespielt
+Played
{totalPlays}