Skip to content
15 changes: 15 additions & 0 deletions lib/view/logged_data_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,21 @@ class _LoggedDataScreenState extends State<LoggedDataScreen> {
}

Future<void> _deleteAllFiles() async {
if (_isLoading) {
return;
}
if (_files.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
appLocalizations.noLoggedData,
style: TextStyle(color: snackBarContentColor),
),
backgroundColor: snackBarBackgroundColor,
),
);
return;
}
Comment on lines +108 to +119

Copilot AI Apr 7, 2026

Copy link

Choose a reason for hiding this comment

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

The _files.isEmpty early-return can be triggered while _loadFiles() is still in progress because _loadFiles() clears _files and sets _isLoading = true. Since the options menu is still available during loading, tapping “Delete All Data” immediately after opening the screen will incorrectly show the “No logged data” snackbar even if files exist.

Consider also guarding on _isLoading (e.g., return early or disable the menu action while loading) so the snackbar only appears when the empty state is final, not transient during refresh/loading.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Diksha-MukherjeeAgarwal, could you please have a look at the Copilot comment and apply the changes if you think they make sense?

final confirmed = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
Expand Down
Loading