SF-3772 Prevent duplicate onboarding requests#3784
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3784 +/- ##
==========================================
- Coverage 81.34% 81.32% -0.02%
==========================================
Files 622 622
Lines 39202 39210 +8
Branches 6401 6403 +2
==========================================
Hits 31889 31889
- Misses 6326 6334 +8
Partials 987 987 ☔ View full report in Codecov by Sentry. |
1c4ac76 to
dec8b56
Compare
marksvc
left a comment
There was a problem hiding this comment.
@marksvc reviewed 5 files and all commit messages, and made 2 comments.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on Nateowami).
src/SIL.XForge.Scripture/ClientApp/src/assets/i18n/non_checking_en.json line 406 at r2 (raw file):
Hmm. If they hear back from the team, can they submit another request?
If not, perhaps this might say
A request to activate drafting on this project has already been submitted. Thank you for your patience in waiting for a response from the team.
Also, we might consider mentioning where they should be looking for a response. An email? A new ability/button present on the Draft Generation page?
src/SIL.XForge.Scripture/ClientApp/src/app/translate/draft-generation/draft-signup-form/draft-onboarding-form.component.ts line 373 at r2 (raw file):
private async hasRequestAlreadyBeenSubmitted(): Promise<boolean> { return (await this.onboardingRequestService.getOpenOnboardingRequest(this.activatedProject.projectId!)) != null;
I think we will do ourselves good to continue to let the type system help us. Rather than introduce the non null assertion operator here, what do you think about using
if (this.activatedProject.projectId == null) return false;
return (await this.onboardingRequestService.getOpenOnboardingRequest(this.activatedProject.projectId)) != null;or
const projectId: string | undefined = this.activatedProject.projectId;
return (projectId == null || (await this.onboardingRequestService.getOpenOnboardingRequest(projectId))) != null;?
Before this change, the UI already informs the user when a request has already been submitted and doesn't allow submitting another. However, the check is only done when the drafting component loads, so by using multiple tabs, or possibly by using browser history, it's possible to submit the form twice. This change adds additional checks to prevent duplicate submissions.
EDIT: I think the actual reason we were getting duplicate requests was network errors when submitting the form:

The request did however get saved, but the client didn't know it, so the user was able to re-submit.
EDIT 2: I think the network errors are timeouts. I've created a PR to fix them: #3785. However, I think this PR is still a good change.
This change is