-
Notifications
You must be signed in to change notification settings - Fork 73
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: disable vote option while loading #3676
Conversation
Signed-off-by: Hamza Mahjoubi <[email protected]>
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.
Looks good!
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.
LGTM, yet let's see what @dartcafe feedback will be.
I can't reproduce it. How did you run into this situation? |
It happens when you double click a vote option ( spamming also works) |
I klicked like a maniac, but the error did not raise, even if I simulate a GPRS bandwidth. But your solution has the side effect, that it lets the background flash unintenionally. click.flashing.mp4I see this issue as not necessary. It would be more valuable, if it would be applied to the next branch, because this branch will be a dead end. Next will replace master as future main branch. |
BTW: Any race condition should be solved by lodash/debounce and request canceling inside the api, so that only the last vote within the debounce timespan should be accepted. If this does not work for any reason, the fix should be applied there. Blocking the vote cell is not a good solution, since it is a bad UX. |
Screen.Recording.2024-08-30.at.13.17.52.movAs you can see in the video the reproduction is pretty straight forward, You just have to double click a vote option
I'm sorry but I don't really understand your argument here. I think that the way it is right now is a bad UX (wrong warning message, and allowing a button press when you shouldn't ) I really think that a good UX in this case is
It is intentional, it indicates that the button is disabled |
First of all: I am still not able to provocate the 409. But there is no reason to disable the current vote cell, with only one exception: The user already has more yes votes than allowed. In this case changing the vote from "yes" to "no" disables the current vote cell. A race condition, caused by clicking while the request is still ongoing, should be captured by loadash/debounce or by cancelling previous request. In the result only the last vote is to be persisted. This is, why I want to understand, under which circumstances the 409 occurs, because it should not. |
Buut. Luckily after "a million" clicks and getting the exact click frequence needed, I now managed to get the 409 and see what happened. Wow, this is a very rare edge case with my setup. Explanation: Currently this error is handeled by capturing it and reload the votes and the options to get a consistent state. But here we also have to reload the poll information, because the information about the remaining votes went there. polls/src/js/store/modules/votes.js Lines 107 to 116 in 54334fe
Now we can follow two strategies:
polls/lib/Service/VoteService.php Lines 71 to 85 in 54334fe
polls/src/js/store/modules/votes.js Lines 107 to 116 in 54334fe
|
And thinking further about it, I believe both strategies should be applied.
A further optimization would be to avoid two requests, by directly return the poll and options upon voting. I will directly add a commit, since I currently have the particular code opened. |
Signed-off-by: dartcafe <[email protected]>
Signed-off-by: dartcafe <[email protected]>
Signed-off-by: dartcafe <[email protected]>
Signed-off-by: dartcafe <[email protected]>
5ac9ce2
What I did:
This should avoid the 409 error in this cases, avoid some additional requests and secures a better UX, because the vote cell gets not blocked by fast clicking. |
Signed-off-by: dartcafe <[email protected]>
Since there wasn't any warning displayed to the user, I don't see any UX issue. What warning are you referring to? The bad UX was the misinformation about the left votes, which was wrong (you can see it in the last seconds of your video).
And this is exatly what I intended to avoid and understand as a bad UX, since blocking prior votes is unnecessary. Only my last vote counts. For example in case of a laggy connection, it may be annoying, if I have to wait for the responses which are simply no more valid, to be able to set my decision of the vote. Therefore prior unfulfilled votes get discarded instead of waiting for the commits. |
@hamza221 I tested the changes quite some time:
Do you want to review that? |
I can't reproduce anymore ✅ |
Just a recap: Understandable, why this happened. 💡 If the db state is 'yes' and only the last 'yes'-vote gets through (prior votes get discarded) the exception gets triggered, if the allowed number of remaining votes is 0. Then the limit check returns the exception, regardless if the vote does not change the number of used votes. Anyway strange I could not reproduce it from the start. |
Yes, has been quite a rabbithole to jump into 👍 |
Without this you can run into this bug