diff --git a/lib/screens/home_shell.dart b/lib/screens/home_shell.dart index 1a0590e..e833375 100644 --- a/lib/screens/home_shell.dart +++ b/lib/screens/home_shell.dart @@ -15,6 +15,8 @@ class _HomeShellState extends State { int _currentIndex = 0; final _collectionsKey = GlobalKey(); final _scanKey = GlobalKey(); + final Map _lastRefreshed = {}; + static const _refreshDebounce = Duration(seconds: 30); late final List _pages = [ CollectionsScreen(key: _collectionsKey), @@ -24,10 +26,13 @@ class _HomeShellState extends State { void _onTabSelected(int i) { setState(() => _currentIndex = i); + final now = DateTime.now(); + final last = _lastRefreshed[i]; + if (last != null && now.difference(last) < _refreshDebounce) return; + _lastRefreshed[i] = now; if (i == 0) { _collectionsKey.currentState?.refresh(); - } - if (i == 1) { + } else if (i == 1) { _scanKey.currentState?.refresh(); } }