From f2f624f2aa50cf890abbf74657f73bb08afa9655 Mon Sep 17 00:00:00 2001 From: Midhun Suresh <midhunr@element.io> Date: Fri, 4 Feb 2022 12:54:37 +0530 Subject: [PATCH] Use new registration API --- src/viewmodels/AccountSetupViewModel.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts index a774c1f..6c874e9 100644 --- a/src/viewmodels/AccountSetupViewModel.ts +++ b/src/viewmodels/AccountSetupViewModel.ts @@ -10,6 +10,7 @@ export class AccountSetupViewModel extends ViewModel { private _termsStage?: any; private _password: string; private _username: string; + private _registration: any; constructor(options) { super(options); @@ -24,7 +25,8 @@ export class AccountSetupViewModel extends ViewModel { for (let i = 0; i < maxAttempts; ++i) { try { this._username = `${this._config.username_prefix}-${generateUsername(10)}`; - let stage = await this._client.startRegistration(this._homeserver, this._username, this._password, "Chatterbox"); + this._registration = await this._client.startRegistration(this._homeserver, this._username, this._password, "Chatterbox"); + const stage = await this._registration.start(); if (stage.type === "m.login.terms") { this._termsStage = stage; this.emitChange("termsStage"); @@ -41,8 +43,8 @@ export class AccountSetupViewModel extends ViewModel { async completeRegistration() { let stage = this._termsStage; - while (typeof stage !== "string") { - stage = await stage.complete(); + while (stage) { + stage = await this._registration.submitStage(stage); } const loginPromise = this.login(this._username, this._password); this.navigation.push("timeline", loginPromise); -- GitLab