diff --git a/lib/screens/authentification/authenticate_page.dart b/lib/screens/authentification/authenticate_page.dart index 2b3e99ea..b85443b0 100644 --- a/lib/screens/authentification/authenticate_page.dart +++ b/lib/screens/authentification/authenticate_page.dart @@ -300,7 +300,7 @@ class _FullAppLogo extends StatelessWidget { @override Widget build(BuildContext context) { return RepeatedTapDetector( - onRepeatedTap: _downloadLogs, + onRepeatedTap: () => _downloadLogs(context), tapTriggerCount: 7, child: SizedBox( height: 240, @@ -315,8 +315,19 @@ class _FullAppLogo extends StatelessWidget { /// download the logs and share them via the system share sheet. This is so /// that users can download logs even if they can't access the settings page. /// E.g. if the app crashes on login. - void _downloadLogs() { - Log.downloadLogs().ignore(); + void _downloadLogs(BuildContext context) { + Log.downloadLogs().catchError((e) { + _showSnackbar(context, e.toString()); + }); + } + + void _showSnackbar(BuildContext context, String message) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + duration: const Duration(seconds: 3), + ), + ); } } diff --git a/lib/screens/settings/setting_page.dart b/lib/screens/settings/setting_page.dart index c43fef67..b9638a24 100644 --- a/lib/screens/settings/setting_page.dart +++ b/lib/screens/settings/setting_page.dart @@ -557,7 +557,20 @@ class _SettingPageState extends State { Future _shareLogs() async { Navigator.of(context).pop(); - Log.downloadLogs().ignore(); + Log.downloadLogs().catchError((dynamic e) { + _showSnackbar(e.toString()); + }); + } + + void _showSnackbar(String message) { + if (context == null) return; + + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(message), + duration: const Duration(seconds: 3), + ), + ); } Future _shareFileDialog() async { diff --git a/lib/utils/log.dart b/lib/utils/log.dart index 4d14a18d..a7747a10 100644 --- a/lib/utils/log.dart +++ b/lib/utils/log.dart @@ -153,6 +153,9 @@ class Log { // Discord attachment size limit is about 25 MiB final exportedLogFiles = (await LogStorage().exportLogs()).map((f) => XFile(f.path)).toList(); + if (exportedLogFiles.isEmpty) { + throw Exception('No logs to download'); + } mainBloc.isUrlLaucherIsOpen = true;