-
Notifications
You must be signed in to change notification settings - Fork 2
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
Refactor: extract button Toast display logic to prevent spamming #254
Conversation
|
This PR will be transformed to an all-purpose utility addition for |
I've spent quite a bit of time searching for a solution to test So instead, I wrote a simple unit test, that checks the functionality of the utility object. Regarding the low coverage, it's because lots of |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not much to say, good job and LGTM
This is a very small PR following the what I mentioned in this comment of PR #240:
I unfortunately forgot to include the Toast addition to that PR, so here it is. Note that I defined a very simple logic to prevent the toasts from showing on top of each other if the user spams the
More...
button, e.g. only oneToast
shows up at a time. This is a logic we could use in all places where we showToasts
as such, and use a custom class for it, but for now this suffices for the purpose of this PR.Description
This PR introduces a utility mechanism to prevent the spamming of
Toast
messages in the app. The utility ensures that only one Toast can be displayed at a time, canceling the currently active Toast before showing a new one.Motivation and Context
There are UI elements such as buttons that display Toast messages when clicked. A user could spam these buttons to repeatedly show Toast messages, and waste their system's resources. This PR implements a solution to mitigate this issue and ensure to Toasts do not show up one behind another at the same time when these spams occur.
ToastUtils
Various screens:
How has this been tested?
Wrote a unit test (ToastUtilsMockTest) to verify the functionality, e.g. that the currently active Toast is canceled before displaying a new one.