From e500fe452dda5d3aa3a767de3702dd3fa5317d2b Mon Sep 17 00:00:00 2001 From: Sam Matthews <75203773+TheLidlMan@users.noreply.github.com> Date: Wed, 5 Nov 2025 11:39:29 +0000 Subject: [PATCH] fix: when navigating back to home screen it does full screen refresh, making it feel slow now it just refreshes the continue watching tab and keeps everything else the same. --- lib/screens/discover_screen.dart | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/screens/discover_screen.dart b/lib/screens/discover_screen.dart index 4d7d11cc..b1c217f1 100644 --- a/lib/screens/discover_screen.dart +++ b/lib/screens/discover_screen.dart @@ -239,11 +239,46 @@ class _DiscoverScreenState extends State } } + /// Refresh only the Continue Watching section in the background + /// This is called when returning to the home screen to avoid blocking UI + Future _refreshContinueWatching() async { + appLogger.d('Refreshing Continue Watching in background'); + + try { + final clientProvider = context.plexClient; + final client = clientProvider.client; + if (client == null) { + appLogger.w('No client available for background refresh'); + return; + } + + final onDeck = await client.getOnDeck(); + + if (mounted) { + setState(() { + _onDeck = onDeck; + // Reset hero index if needed + if (_currentHeroIndex >= onDeck.length) { + _currentHeroIndex = 0; + if (_heroController.hasClients && onDeck.isNotEmpty) { + _heroController.jumpToPage(0); + } + } + }); + appLogger.d('Continue Watching refreshed successfully'); + } + } catch (e) { + appLogger.w('Failed to refresh Continue Watching', error: e); + // Silently fail - don't show error to user for background refresh + } + } + // Public method to refresh content @override void refresh() { appLogger.d('DiscoverScreen.refresh() called'); - _loadContent(); + // Only refresh Continue Watching in background, not full screen reload + _refreshContinueWatching(); } /// Get icon for hub based on its title