From c3f476c7d781b646ab48f48d99b8d04e01d17612 Mon Sep 17 00:00:00 2001 From: RMidhunSuresh <hi@midhun.dev> Date: Tue, 8 Mar 2022 13:45:10 +0530 Subject: [PATCH] Check condition outside loop --- src/viewmodels/AccountSetupViewModel.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts index 4693f55..2444ef3 100644 --- a/src/viewmodels/AccountSetupViewModel.ts +++ b/src/viewmodels/AccountSetupViewModel.ts @@ -28,13 +28,13 @@ export class AccountSetupViewModel extends ViewModel { this._registration = await this._client.startRegistration(this._homeserver, username, this._password, "Chatterbox"); this._startStage = await this._registration.start(); let stage = this._startStage; - while (stage.type !== "m.login.terms") { + while (stage && stage.type !== "m.login.terms") { stage = stage.nextStage; - if (!stage) { - // If terms login stage is not found, go straight to completeRegistration() - this.completeRegistration(); - return; - } + } + if (!stage) { + // If terms login stage is not found, go straight to completeRegistration() + this.completeRegistration(); + return; } this._privacyPolicyLink = stage.privacyPolicy.en?.url; this.emitChange("privacyPolicyLink"); -- GitLab