()
| 476 | } |
| 477 | |
| 478 | checkName () { |
| 479 | const name = this.$('input[name="name"]').val() |
| 480 | |
| 481 | if (name === this.state.get('checkNameValue')) { |
| 482 | return this.state.get('checkNamePromise') |
| 483 | } |
| 484 | |
| 485 | if (!name) { |
| 486 | this.state.set({ |
| 487 | checkNameState: 'standby', |
| 488 | checkNameValue: name, |
| 489 | checkNamePromise: null |
| 490 | }) |
| 491 | return Promise.resolve() |
| 492 | } |
| 493 | |
| 494 | this.state.set({ |
| 495 | checkNameState: 'checking', |
| 496 | checkNameValue: name, |
| 497 | |
| 498 | checkNamePromise: (User.checkNameConflicts(name) |
| 499 | .then(({ suggestedName, conflicts }) => { |
| 500 | if (name !== this.$('input[name="name"]').val()) { return } |
| 501 | if (conflicts) { |
| 502 | const suggestedNameText = $.i18n.t('signup.name_taken').replace('{{suggestedName}}', suggestedName) |
| 503 | return this.state.set({ checkNameState: 'exists', suggestedNameText }) |
| 504 | } else { |
| 505 | return this.state.set({ checkNameState: 'available' }) |
| 506 | } |
| 507 | }) |
| 508 | .catch(error => { |
| 509 | this.state.set('checkNameState', 'standby') |
| 510 | throw error |
| 511 | })) |
| 512 | }) |
| 513 | |
| 514 | return this.state.get('checkNamePromise') |
| 515 | } |
| 516 | |
| 517 | onChangeEmail (e) { |
| 518 | this.updateAuthModalInitialValues({ email: this.$(e.currentTarget).val() }) |
no test coverage detected