mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-11 17:30:00 +02:00
fix(mobile): stabilize router and add loading timeout/retry on playlists screen
This commit is contained in:
1 parent
180b57e1b7
commit
e4f8ebcf8f
2 files changed
+26
-4
No files matched your search
@@ -13,12 +13,11 @@ import '../widgets/themed_loading_screen.dart';
|
||||
import '../../features/iptv/providers/xtream_provider.dart';
|
||||
|
||||
final routerProvider = Provider<GoRouter>((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<GoRouter>((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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user