fix: don't update profile until user controller initialized, redirect to rooms from SSO login, in create account page redirect to language selection page if no language available (#4274)

This commit is contained in:
ggurdin 2025-10-08 09:27:00 -04:00 committed by GitHub
parent b06b1ff16c
commit 0c5a57bc3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View file

@ -131,6 +131,7 @@ class CreatePangeaAccountPageState extends State<CreatePangeaAccountPage> {
}
Future<void> _updateTargetLanguage() async {
if (_langCode == null) return;
await MatrixState.pangeaController.userController.updateProfile(
(profile) {
profile.userSettings.targetLanguage = _langCode;
@ -150,7 +151,12 @@ class CreatePangeaAccountPageState extends State<CreatePangeaAccountPage> {
try {
if (_langCode == null) {
throw Exception('No language selected');
// at this point, there's no cached selected language, and couldn't get
// language from cached course code, so go back to the language selection page
if (mounted) {
context.go('/registration');
}
return;
}
final updateFuture = [

View file

@ -62,7 +62,7 @@ Future<void> pangeaSSOLoginAction(
final route = FluffyChatApp.router.state.fullPath;
if (route == null ||
(!route.contains("/rooms") && !route.contains('registration'))) {
context.go('/registration/create');
context.go('/rooms');
}
},
).timeout(const Duration(seconds: 30));
@ -77,7 +77,7 @@ Future<void> pangeaSSOLoginAction(
final route = FluffyChatApp.router.state.fullPath;
if (route == null ||
(!route.contains("/rooms") && !route.contains('registration'))) {
context.go('/registration/create');
context.go('/rooms');
}
} else {
await redirect;

View file

@ -106,6 +106,7 @@ class UserController {
Profile Function(Profile) update, {
waitForDataInSync = false,
}) async {
await initialize();
final prevTargetLang = _pangeaController.languageController.userL2;
final prevBaseLang = _pangeaController.languageController.userL1;
final prevHash = profile.hashCode;