Skip to content

Make sure Snackbars are only displayed once #1175

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

Merged
merged 4 commits into from
Aug 30, 2023

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Aug 29, 2023

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

  • Made SnackbarDispatcher.snackbarMessage a Flow backed by a queue.
  • Added SnackbarMessage.isDisplayed property to check if the message is already being displayed.
  • Clears the SnackbarDispatcher queue too when the coroutine displaying the current message is cancelled.

Motivation and context

Fixes #928.

Tests

In an unverified session:

  • Go to Settings -> Complete verification.
  • Finish the verification.
  • See the snackbar being displayed.
  • Go back to the room list. No snackbar should be displayed here.

An alternative test is to go to your home screen and then back to the app.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 11.

Checklist

@jmartinesp jmartinesp requested a review from a team as a code owner August 29, 2023 13:40
@jmartinesp jmartinesp requested review from julioromano and removed request for a team August 29, 2023 13:40
@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2023

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/fVXJFF

@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Patch coverage: 78.26% and project coverage change: -0.01% ⚠️

Comparison is base (5a85459) 56.87% compared to head (e4f6071) 56.86%.
Report is 5 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1175      +/-   ##
===========================================
- Coverage    56.87%   56.86%   -0.01%     
===========================================
  Files         1039     1039              
  Lines        26812    26817       +5     
  Branches      5544     5549       +5     
===========================================
+ Hits         15248    15250       +2     
+ Misses        9168     9167       -1     
- Partials      2396     2400       +4     
Files Changed Coverage Δ
...t/android/libraries/designsystem/utils/Snackbar.kt 68.29% <78.26%> (-3.93%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

data class SnackbarMessage(
/** The message to be displayed. */

Choose a reason for hiding this comment

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

Shouldn't these lines go in the class's docstring?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you're right.

fun clear() {
if (snackBarMessageQueue.isNotEmpty()) {
snackBarMessageQueue.removeFirstOrNull()
if (queueMutex.isLocked) queueMutex.unlock()
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering if it would be useful to add some unit test to cover this.

Copy link
Member Author

Choose a reason for hiding this comment

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

True, it should be easier to test now.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@jmartinesp jmartinesp merged commit 36f0bec into develop Aug 30, 2023
@jmartinesp jmartinesp deleted the fix/jme/928-snackbar-are-displayed-too-much branch August 30, 2023 08:43
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.

"Verification complete" snackbar is shown too much
3 participants