From e4f8ebcf8fe6759d624b5b2b0a79d98d7cb05046 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 9 Mar 2026 17:35:09 +0100 Subject: [PATCH] fix(mobile): stabilize router and add loading timeout/retry on playlists screen --- lib/core/router/app_router.dart | 8 ++++--- .../mobile_playlist_selection_screen.dart | 22 ++++++++++++++++++- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/core/router/app_router.dart b/lib/core/router/app_router.dart index 4a3f0cc..ae2268e 100644 --- a/lib/core/router/app_router.dart +++ b/lib/core/router/app_router.dart @@ -13,12 +13,11 @@ import '../widgets/themed_loading_screen.dart'; import '../../features/iptv/providers/xtream_provider.dart'; final routerProvider = Provider((ref) { - final authState = ref.watch(authProvider); - return GoRouter( initialLocation: '/login', refreshListenable: RouterRefreshNotifier(ref), redirect: (context, state) { + final authState = ref.read(authProvider); final isLoggedIn = authState.isAuthenticated; final isLoginRoute = state.matchedLocation == '/login'; @@ -97,12 +96,15 @@ final routerProvider = Provider((ref) { ); }); -/// Notifier that triggers router refresh when auth state changes +/// Notifier that triggers router refresh when auth state or selected playlist changes class RouterRefreshNotifier extends ChangeNotifier { RouterRefreshNotifier(this._ref) { _ref.listen(authProvider, (_, __) { notifyListeners(); }); + _ref.listen(selectedPlaylistProvider, (_, __) { + notifyListeners(); + }); } final Ref _ref; diff --git a/lib/mobile/features/iptv/screens/mobile_playlist_selection_screen.dart b/lib/mobile/features/iptv/screens/mobile_playlist_selection_screen.dart index e4278e3..25f72eb 100644 --- a/lib/mobile/features/iptv/screens/mobile_playlist_selection_screen.dart +++ b/lib/mobile/features/iptv/screens/mobile_playlist_selection_screen.dart @@ -40,7 +40,27 @@ class MobilePlaylistSelectionScreen extends ConsumerWidget { ], ), body: playlistsAsync.when( - loading: () => const Center(child: CircularProgressIndicator()), + loading: () => Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const CircularProgressIndicator(), + const SizedBox(height: 24), + FutureBuilder( + future: Future.delayed(const Duration(seconds: 5)), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return TextButton( + onPressed: () => ref.refresh(playlistsProvider), + child: const Text('Still loading? Tap to retry'), + ); + } + return const SizedBox.shrink(); + }, + ), + ], + ), + ), error: (error, stack) => Center( child: Column( mainAxisAlignment: MainAxisAlignment.center,