Skip to content

fix: add snackbar for empty logged data#3162

Merged
marcnause merged 8 commits into
fossasia:flutterfrom
Diksha-MukherjeeAgarwal:patch-2
Apr 12, 2026
Merged

fix: add snackbar for empty logged data#3162
marcnause merged 8 commits into
fossasia:flutterfrom
Diksha-MukherjeeAgarwal:patch-2

Conversation

@Diksha-MukherjeeAgarwal

@Diksha-MukherjeeAgarwal Diksha-MukherjeeAgarwal commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?
This PR updates the _deleteAllFiles() function in logged_data_screen.dart.

Why is this change needed?
Previously, if the user clicked "Delete All Files" when the list was empty, it would still show the delete confirmation dialog.
This update adds a check so that if _files.isEmpty is true, it shows a Snackbar.

Summary by Sourcery

Handle attempts to delete logged data when no files are present by providing user feedback instead of showing a confirmation dialog.

Bug Fixes:

  • Prevent the delete-all confirmation dialog from appearing when there are no logged data files to delete.

Enhancements:

  • Show a localized snackbar message to inform the user when there is no logged data to delete.

@sourcery-ai

sourcery-ai Bot commented Apr 2, 2026

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds an early-return guard in _deleteAllFiles to show a localized snackbar when there are no logged files instead of opening the delete confirmation dialog.

Sequence diagram for _deleteAllFiles snackbar behavior

sequenceDiagram
  actor User
  participant LoggedDataScreenState
  participant ScaffoldMessenger
  participant Dialog

  User->>LoggedDataScreenState: tapDeleteAllFiles()
  LoggedDataScreenState->>LoggedDataScreenState: _deleteAllFiles()
  alt files list is empty
    LoggedDataScreenState->>ScaffoldMessenger: showSnackBar(noLoggedData)
    ScaffoldMessenger-->>User: displaySnackbar(noLoggedData)
  else files list is not empty
    LoggedDataScreenState->>Dialog: showDialog(confirmDeleteAll)
    Dialog-->>User: displayConfirmation()
    User-->>Dialog: confirm()
    Dialog-->>LoggedDataScreenState: confirmed true
    LoggedDataScreenState->>LoggedDataScreenState: proceedWithDeletion()
  end
Loading

File-Level Changes

Change Details Files
Guard empty file list deletions by showing a localized snackbar and skipping the confirmation dialog and deletion flow.
  • Add an early return in _deleteAllFiles when the in-memory file list is empty
  • Display a SnackBar via ScaffoldMessenger with localized 'no logged data' text
  • Apply custom text and background colors for the snackbar content using existing snackbar color constants
  • Preserve the existing confirmation dialog flow for non-empty file lists
lib/view/logged_data_screen.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've left some high level feedback:

  • Consider disabling or hiding the "Delete All Files" action when _files.isEmpty instead of showing a Snackbar, so users get immediate visual feedback that there is nothing to delete before tapping.
  • If this snackbar pattern (colors, style, localization) is or will be used elsewhere, consider extracting a small helper method or widget for showing app-standard snackbars to keep styling and behavior consistent.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider disabling or hiding the "Delete All Files" action when `_files.isEmpty` instead of showing a Snackbar, so users get immediate visual feedback that there is nothing to delete before tapping.
- If this snackbar pattern (colors, style, localization) is or will be used elsewhere, consider extracting a small helper method or widget for showing app-standard snackbars to keep styling and behavior consistent.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Diksha-MukherjeeAgarwal Diksha-MukherjeeAgarwal changed the title Add snackbar for empty logged data Fix: add snackbar for empty logged data Apr 2, 2026
@Diksha-MukherjeeAgarwal Diksha-MukherjeeAgarwal changed the title Fix: add snackbar for empty logged data fix: add snackbar for empty logged data Apr 2, 2026

@rahul31124 rahul31124 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice addition! This will improve the user experience

Copilot AI left a comment

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.

Pull request overview

This PR improves the Logged Data UI flow by providing immediate user feedback when “Delete All Data” is invoked with an empty logged-data list, avoiding an unnecessary confirmation dialog.

Changes:

  • Add an early return in _deleteAllFiles() when _files is empty.
  • Show a localized SnackBar (“noLoggedData”) instead of opening the delete-all confirmation dialog in the empty state.

Comment on lines +105 to +116
if (_files.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
appLocalizations.noLoggedData,
style: TextStyle(color: snackBarContentColor),
),
backgroundColor: snackBarBackgroundColor,
),
);
return;
}

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?

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Build Status

Build successful. APKs to test: https://github.com/fossasia/pslab-app/actions/runs/24309661880/artifacts/6393541941.

Screenshots

Android Screenshots
iPhone Screenshots
iPad Screenshots

@marcnause marcnause merged commit 83c3315 into fossasia:flutter Apr 12, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants