Skip to content

Commit 19d1220

Browse files
fix: Close registration modal after successful password registration
The registration modal was not being closed after successful password-based registration, causing it to block all UI interactions even though it was invisible (hidden along with the registration screen). Added RegisterAction::RegistrationSuccess to properly close the modal before transitioning to the main screen. Also improved comments to explain why LoginBySSOSuccess is used for the post-registration flow. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 58fae97 commit 19d1220

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/sliding_sync.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ pub enum LoginRequest{
566566
LoginBySSOSuccess(Client, ClientSessionPersisted),
567567
LoginByCli,
568568
HomeserverLoginTypesQuery(String),
569-
570569
}
571570
/// Information needed to log in to a Matrix homeserver.
572571
pub struct LoginByPassword {
@@ -612,12 +611,20 @@ async fn async_worker(
612611
rt.spawn(async move {
613612
match register_user(register_request).await {
614613
Ok((client, client_session)) => {
615-
// After successful registration, we need to set up the client session
616-
// and initialize all the global state (CLIENT, SLIDING_SYNC, etc.)
617-
// The login flow already handles all of this setup properly,
618-
// so we reuse it by converting the registration success into a login success.
619-
// This ensures consistent state initialization regardless of whether
620-
// the user registered or logged in directly.
614+
// Send RegistrationSuccess action to close the registration modal
615+
Cx::post_action(RegisterAction::RegistrationSuccess);
616+
617+
// After successful registration, we need to initialize all the global state
618+
// (CLIENT, SLIDING_SYNC, room lists, etc.) which is handled by the main login flow.
619+
//
620+
// We use LoginBySSOSuccess (not LoginByPassword) because:
621+
// 1. Registration already authenticated us - we have a valid client and session
622+
// 2. We don't need to login again (which LoginByPassword would do)
623+
// 3. LoginBySSOSuccess simply passes through the already-authenticated client
624+
// without making any network requests - it only saves the session locally
625+
//
626+
// The name is misleading - it's really "UseAuthenticatedClient" that works for
627+
// any pre-authenticated client (SSO, registration, restored session, etc.)
621628
let login_req = LoginRequest::LoginBySSOSuccess(client, client_session);
622629
submit_async_request(MatrixRequest::Login(login_req));
623630
}

0 commit comments

Comments
 (0)