fix: prevent return to profile creation page resetting L2 to null

This commit is contained in:
ggurdin 2025-10-30 13:25:57 -04:00
parent 9959c8a3a9
commit 5400eb1b11
No known key found for this signature in database
GPG key ID: A01CB41737CBB478
2 changed files with 20 additions and 11 deletions

View file

@ -141,14 +141,18 @@ class CreatePangeaAccountPageState extends State<CreatePangeaAccountPage> {
}
}
Future<void> _updateLanguageSettings() async {
final targetLangCode = await _targetLangCode;
final baseLangCode = await _baseLangCode;
Future<void> _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<CreatePangeaAccountPage> {
Future<void> _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.

View file

@ -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"