Fix subscription leak
This commit is contained in:
parent
887b80aee8
commit
32ee928b6c
|
@ -37,20 +37,7 @@ export class RegisterComponent implements OnInit {
|
|||
history.replaceState(null, '');
|
||||
}
|
||||
|
||||
this.model.username.valueChanges
|
||||
.pipe(debounceTime(500))
|
||||
.subscribe(async (value) => {
|
||||
if (this.model.username.errors || value === null) return;
|
||||
|
||||
const result = await this.userService.checkNameIsAvailable(value);
|
||||
if (HasFailed(result))
|
||||
return this.errorService.showFailure(result, this.logger);
|
||||
|
||||
if (!result) {
|
||||
this.model.username.setErrors({ unavailable: true });
|
||||
}
|
||||
});
|
||||
|
||||
this.subscribeUsernameCheck();
|
||||
this.onPermissions();
|
||||
}
|
||||
|
||||
|
@ -101,4 +88,21 @@ export class RegisterComponent implements OnInit {
|
|||
state: this.model.getRawData(),
|
||||
});
|
||||
}
|
||||
|
||||
@AutoUnsubscribe()
|
||||
private subscribeUsernameCheck() {
|
||||
return this.model.username.valueChanges
|
||||
.pipe(debounceTime(500))
|
||||
.subscribe(async (value) => {
|
||||
if (this.model.username.errors || value === null) return;
|
||||
|
||||
const result = await this.userService.checkNameIsAvailable(value);
|
||||
if (HasFailed(result))
|
||||
return this.errorService.showFailure(result, this.logger);
|
||||
|
||||
if (!result) {
|
||||
this.model.username.setErrors({ unavailable: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue