+
+ concat(
+ of(''),
+ this.form.get('displayName').valueChanges
+ ).pipe(pairwise())
+ .subscribe(([ oldValue, newValue ]) => this.onDisplayNameChange(oldValue, newValue))
+ }
+
+ onTermsClick (event: Event) {
+ event.preventDefault()
+ this.termsClick.emit()
+ }
+
+ onCodeOfConductClick (event: Event) {
+ event.preventDefault()
+ this.codeOfConductClick.emit()
+ }
+
+ private onDisplayNameChange (oldDisplayName: string, newDisplayName: string) {
+ const username = this.form.value['username'] || ''
+
+ const newUsername = this.userService.getNewUsername(oldDisplayName, newDisplayName, username)
+ this.form.patchValue({ username: newUsername })