connect
connect copied to clipboard
Fix/con/898 ensure exclusive acceptance of mentors
What Github issue does this PR relate to? Insert link.
#898
This PR fixes bug #898 which allowed mentees in special cases to have two simultaneously active/accepted Mentorship Matches:
The case could happen when for example:
- Eric sends mentorship requests to two mentors, Anil and Kate
- Two Mentorship Matches are created, both with state
Applied
- Anil and Kate access the CON Applications page at the same time
- Anil accepts the mentorship
- Nestjs updates the two Mentorship Mathches:
- The Eric+Anil Mentorship Match becomes
Accepted
- The Eric+Kate Mentorship Match becomes
Invalidated/Cancelled
- Kate accepts the mentorship
- The Eric+Kate Mentorship Match becomes
Accepted
The fix was obvious: in the code that handles the "accept mentorship" mutation, only change the Mentorship Match state into Accepted
if the current state is Applied
.
What should the reviewer know?
The backend issue is solved, and we likely won't get into a state of one mentee + two active mentorships. But an unpleasant UX issue came up:
If the above steps happened again, but with the fix in this PR, Kate would in step 6 be prevented from accepting the mentorship request. Nestjs would return an error handled by the CON frontend in the catch (error) {
clause you'll see. I've implemented a crude alert() shown to the user and then the page refreshes.
That scenario is illustrated in this Loom: https://www.loom.com/share/47fb8764f8d14c619092a3c8a6775b6d?sid=1dd21bcc-d13f-4020-a133-7a91d5bbb265
This leads to the loss of the acceptance message that Kate wrote - which is annoying, but the message isn't relevant any longer since Eric has a mentorship with Anil and isn't supposed to have one with Kate.
The question is: are there any easy ways to improve this UX?