SideBySide2: Avoid duplicate draft creation by fixing race condition
On slower networks/servers users can create duplicate drafts by:
- start typing a new draft comment
- press ctrl + s, u
The ctrl+s key combo starts an RPC to insert the new draft and
transfers focus to another part of the page where u is a valid
key binding to go up to the change. When the u key is processed
the SideBySide2 screen starts to go up, which tries to save all
pending drafts. This starts another RPC to insert the draft. Both
RPCs eventually complete and there are now two identical drafts on
the same line.
Fix this by having the draft box remember which CallbackGroup it
is currently processing for. If another save call arrives before
this is finished the groups are chained together. In the case
describe above the CallbackGroup for the "up to change/save all"
activity will become a listener on the existing save RPC's group,
receiving notification when the save completes.
Change-Id: Ia4ecbb82b6c2866b8faf3d5995c995dca77be28a
3 files changed