Fix action button label changing behavior in MergeUI #8788
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #8655
The MergeUI action button would confusingly change back to "Merge" from "Saving..." or "Done" in the midst of a merge. This PR fixes that behavior.
Technical
The MergeUI interface is designed to change the action button to "Merge" (or "Request Merge") button as soon as enough data has loaded for the merge to complete successfully. This means that when the server is slow, the Merge button will be available before covers, list counts, reading log counts, etc. have loaded. That's the expected behavior.
A previous PR had added a watch function that set the button to "Merge" whenever the internal merge() function returned changed data. The merge() function returns values as soon as a merge is possible, but the returned values change as additional data comes in, so if the user pressed the "Merge" button before e.g. list counts had loaded, and the list counts loaded before the merge was complete, the button would switch from "Saving..." back to "Merge" briefly and then to "Done".
If some of the nonessential data loaded after the merge was complete, the same check would change the button from "Done" back to "Merge".
This PR modifies the behavior of that watch function so that it only changes the button to "Merge" once — when the merge() function first returns data.
Testing
This one is very tricky to test. I had to set up a network debugging tool that would delay lists.api requests by several seconds so that I could reproduce the problem consistently. I solemnly swear that it's fully tested and working. :)
Stakeholders
@mheiman @jimchamp @cdrini @tfmorris @Eds-Dbug