Skip to content

Commit

Permalink
remove error msgs in offline mode
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelladinig committed May 13, 2024
1 parent d0f4441 commit 3845636
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 20 deletions.
41 changes: 25 additions & 16 deletions lib/src/view/puzzle/dashboard_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:lichess_mobile/src/model/puzzle/puzzle.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_providers.dart';
import 'package:lichess_mobile/src/model/puzzle/puzzle_theme.dart';
import 'package:lichess_mobile/src/styles/styles.dart';
import 'package:lichess_mobile/src/utils/connectivity.dart';
import 'package:lichess_mobile/src/utils/l10n_context.dart';
import 'package:lichess_mobile/src/utils/string.dart';
import 'package:lichess_mobile/src/widgets/adaptive_choice_picker.dart';
Expand Down Expand Up @@ -123,25 +124,33 @@ class PuzzleDashboardWidget extends ConsumerWidget {
);
},
error: (e, s) {
final connectivity = ref.watch(connectivityChangesProvider);
final isOnline = connectivity.value?.isOnline ?? true;

debugPrint(
'SEVERE: [PuzzleDashboardWidget] could not load puzzle dashboard; $e\n$s',
);
return Padding(
padding: Styles.bodySectionPadding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.l10n.puzzlePuzzleDashboard,
style: Styles.sectionTitle,
),
if (e is ClientException && e.message.contains('404'))
Text(context.l10n.puzzleNoPuzzlesToShow)
else
const Text('Could not load dashboard.'),
],
),
);

if (!isOnline) {
return Padding(
padding: Styles.bodySectionPadding,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
context.l10n.puzzlePuzzleDashboard,
style: Styles.sectionTitle,
),
if (e is ClientException && e.message.contains('404'))
Text(context.l10n.puzzleNoPuzzlesToShow)
else
const Text('Could not load dashboard.'),
],
),
);
} else {
return const SizedBox.shrink();
}
},
loading: () {
final loaderHeight = MediaQuery.sizeOf(context).width;
Expand Down
16 changes: 12 additions & 4 deletions lib/src/view/puzzle/puzzle_tab_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,21 @@ class PuzzleHistoryWidget extends ConsumerWidget {
);
},
error: (e, s) {
final connectivity = ref.watch(connectivityChangesProvider);
final isOnline = connectivity.value?.isOnline ?? true;

debugPrint(
'SEVERE: [PuzzleHistoryWidget] could not load puzzle history',
);
return Padding(
padding: Styles.bodySectionPadding,
child: const Text('Could not load Puzzle history.'),
);

if (!isOnline) {
return Padding(
padding: Styles.bodySectionPadding,
child: const Text('Could not load Puzzle history.'),
);
} else {
return const SizedBox.shrink();
}
},
loading: () => Shimmer(
child: ShimmerLoading(
Expand Down

0 comments on commit 3845636

Please sign in to comment.