diff --git a/src/App.tsx b/src/App.tsx index ac3bbe0..a2e29c0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,6 +11,7 @@ export default function App() { const [transactions, setTransactions] = useState([]); const [stats, setStats] = useState(null); const [loading, setLoading] = useState(true); + const [refreshing, setRefreshing] = useState(false); const [source, setSource] = useState<'live' | 'mock'>('mock'); useEffect(() => { @@ -18,14 +19,19 @@ export default function App() { const load = (showLoading: boolean) => { if (showLoading) setLoading(true); - fetchData(periodDays).then(({ transactions, stats, source }) => { - if (!cancelled) { - setTransactions(transactions); - setStats(stats); - setSource(source); - setLoading(false); - } - }); + else setRefreshing(true); + fetchData(periodDays) + .then(({ transactions, stats, source }) => { + if (!cancelled) { + setTransactions(transactions); + setStats(stats); + setSource(source); + } + }) + .catch((err) => console.warn('Ğ1Flux refresh error:', err)) + .finally(() => { + if (!cancelled) { setLoading(false); setRefreshing(false); } + }); }; load(true); @@ -59,7 +65,9 @@ export default function App() { ? 'bg-emerald-950/80 border-emerald-700 text-emerald-400' : 'bg-[#0a0b0f]/80 border-[#2e2f3a] text-[#4b5563]' }`}> - {source === 'live' ? '● live Ğ1v2' : '○ mock'} + {source === 'live' + ? <>{refreshing ? : '●'} live Ğ1v2 + : '○ mock'} )}