From f1056023da6078964086dca180f051e8fe5a34f8 Mon Sep 17 00:00:00 2001
From: RMidhunSuresh <hi@midhun.dev>
Date: Tue, 8 Mar 2022 13:29:06 +0530
Subject: [PATCH] Don't die if terms login stage is not found

---
 src/viewmodels/AccountSetupViewModel.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/viewmodels/AccountSetupViewModel.ts b/src/viewmodels/AccountSetupViewModel.ts
index 47a6507..4693f55 100644
--- a/src/viewmodels/AccountSetupViewModel.ts
+++ b/src/viewmodels/AccountSetupViewModel.ts
@@ -31,7 +31,9 @@ export class AccountSetupViewModel extends ViewModel {
                 while (stage.type !== "m.login.terms") {
                     stage = stage.nextStage;
                     if (!stage) {
-                        throw new Error("Terms login stage not found");
+                        // If terms login stage is not found, go straight to completeRegistration()
+                        this.completeRegistration();
+                        return;
                     }
                 }
                 this._privacyPolicyLink = stage.privacyPolicy.en?.url;
-- 
GitLab