From 5400eb1b11fa889f10babeef4b1f08b4f7e137e2 Mon Sep 17 00:00:00 2001 From: ggurdin Date: Thu, 30 Oct 2025 13:25:57 -0400 Subject: [PATCH] fix: prevent return to profile creation page resetting L2 to null --- .../pages/create_pangea_account_page.dart | 29 ++++++++++++------- pubspec.yaml | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/pangea/login/pages/create_pangea_account_page.dart b/lib/pangea/login/pages/create_pangea_account_page.dart index e199c2d12..3a5b6309c 100644 --- a/lib/pangea/login/pages/create_pangea_account_page.dart +++ b/lib/pangea/login/pages/create_pangea_account_page.dart @@ -141,14 +141,18 @@ class CreatePangeaAccountPageState extends State { } } - Future _updateLanguageSettings() async { - final targetLangCode = await _targetLangCode; - final baseLangCode = await _baseLangCode; + Future _updateLanguageSettings(String target, String? base) async { + final profile = MatrixState.pangeaController.userController.profile; + if (profile.userSettings.targetLanguage == target && + profile.userSettings.sourceLanguage == base) { + return; + } + await MatrixState.pangeaController.userController.updateProfile( (profile) { - profile.userSettings.targetLanguage = targetLangCode; - if (baseLangCode != null) { - profile.userSettings.sourceLanguage = baseLangCode; + profile.userSettings.targetLanguage = target; + if (base != null) { + profile.userSettings.sourceLanguage = base; } return profile; }, @@ -158,16 +162,21 @@ class CreatePangeaAccountPageState extends State { Future _createUserInPangea() async { final l2Set = await MatrixState.pangeaController.userController.isUserL2Set; + final baseLangCode = await _baseLangCode; + final targetLangCode = await _targetLangCode; + if (l2Set) { - await _updateLanguageSettings(); + if (targetLangCode == null) { + context.go('/registration/course'); + return; + } + + await _updateLanguageSettings(targetLangCode, baseLangCode); _onProfileCreated(); return; } try { - final baseLangCode = await _baseLangCode; - final targetLangCode = await _targetLangCode; - // User's L2 is not set and they niether have a target language in their // local storage nor can they get it from a course they plan to join. // Redirect back to language selection. diff --git a/pubspec.yaml b/pubspec.yaml index 951b4e7b2..df1243788 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -6,7 +6,7 @@ description: Learn a language while texting your friends. # Pangea# publish_to: none # On version bump also increase the build number for F-Droid -version: 4.1.14+2 +version: 4.1.14+3 environment: sdk: ">=3.0.0 <4.0.0"