Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove error msgs in offline mode #680

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change doesn't make sense anymore I find, since now the dashboard is in its own screen.

I'd leave it as it was.

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is makes sense, since the whole puzzle tab reacts to connectivity. 👍

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