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

fix: LoadingSnackBar consistently remains visible until the upload is complete #1533

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dohoanggiahuy317
Copy link

@dohoanggiahuy317 dohoanggiahuy317 commented Dec 23, 2024

  • Adjusted the SendFileDialogState file to ensure that the showLoadingSnackBar remains visible throughout the file upload process.
  • the SnackBar is cleared only after the image/file is uploaded and displayed in the chat.

Thank you so much for your contribution to FluffyChat ❤️❤️❤️

Please make sure that your Pull Request meet the following acceptance criteria:

  • Code formatting and import sorting has been done with dart format lib/ test/ and dart run import_sorter:main --no-comments
  • The commit message uses the format of Conventional Commits
  • The commit message describes what has been changed, why it has been changed and how it has been changed
  • Every new feature or change of the design/GUI is linked to an approved design proposal in an issue
  • Every new feature in the app or the build system has a strategy how this will be tested and maintained from now on for every release, e.g. a volunteer who takes over maintainership

Pull Request has been tested on:

  • Android
  • iOS
  • Browser (Chromium based)
  • Browser (Firefox based)
  • Browser (WebKit based)
  • Desktop Linux
  • Desktop Windows
  • Desktop macOS

… complete

- Adjusted the `SendFileDialogState` file to ensure that the `showLoadingSnackBar` remains visible throughout the file upload process.
- the SnackBar is cleared only after the image/file is uploaded and displayed in the chat.
@dohoanggiahuy317
Copy link
Author

This change addresses a UX issue where the loading SnackBar was not visible during critical operations like file compression and uploading, making the app appear frozen to the user.

The root cause of this issue is the blocking of the main thread. For example:

  • Heavy operations like reading large files (await xfile.readAsBytes()) or compressing videos (await xfile.resizeVideo()) block the main thread, preventing the UI from updating and showing the SnackBar in time.

  • Additionally, the showSnackBar call is made, but the synchronous or blocking nature of these operations doesn't give Flutter a chance to render the UI before the next task begins.

  • Flutter’s rendering pipeline prioritizes certain tasks, meaning expensive computations can delay the SnackBar’s visibility.

Previously, the SnackBar was cleared and replaced multiple times (e.g., for preparing uploads, compressing, and uploading). This approach not only caused redundant updates but also compounded the blocking issue, making the UI seem unresponsive.

To resolve this, the SnackBar now stays visible throughout the entire process, providing consistent feedback from start to finish. By not clearing and replacing it repeatedly, I ensure that the UI remains informative and responsive, giving users confidence that the app is working and their file will be uploaded successfully.

Copy link
Owner

@krille-chan krille-chan left a comment

Choose a reason for hiding this comment

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

Works fine for me :) Thank you very much

@krille-chan
Copy link
Owner

@dohoanggiahuy317 Can you please sign your commit?

… complete

- Adjusted the `SendFileDialogState` file to ensure that the `showLoadingSnackBar` remains visible throughout the file upload process.
- the SnackBar is cleared only after the image/file is uploaded and displayed in the chat.

Signed-off-by: JaWeee <[email protected]>
@dohoanggiahuy317
Copy link
Author

@dohoanggiahuy317 Can you please sign your commit?

Thank you so much for your approval! I’ve successfully signed the commit. Please let me know if there’s anything further I need to complete 😊

@krille-chan krille-chan enabled auto-merge January 4, 2025 13:21
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.

2 participants