Skip to content

Commit e070f6f

Browse files
fix: Registration modal and sync state improvements
- Close registration modal after successful password registration Previously the modal remained invisible but active, blocking UI interactions - Prevent false offline notifications for normal sync states Only Error, Terminated, and Offline states now trigger connection error popups Idle and Running states are normal operational states This fixes issues where users would see incorrect error messages after registration when the sync service is actually working properly.
1 parent 6509e20 commit e070f6f

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

src/home/rooms_list_header.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,21 @@ impl Widget for RoomsListHeader {
104104
if &self.sync_state == new_state {
105105
continue;
106106
}
107-
log!("Setting the RoomsListHeader to offline.");
108-
self.view.view(id!(loading_spinner)).set_visible(cx, false);
109-
self.view.view(id!(synced_icon)).set_visible(cx, false);
110-
self.view.view(id!(offline_icon)).set_visible(cx, true);
111-
enqueue_popup_notification(PopupItem {
112-
message: "Cannot reach the Matrix homeserver. Please check your connection.".into(),
113-
auto_dismissal_duration: None,
114-
kind: PopupKind::Error,
115-
});
107+
108+
// Only show offline notification for actual connection errors
109+
// States like Idle and Running are normal and shouldn't trigger error popups
110+
if matches!(new_state, State::Error | State::Terminated | State::Offline) {
111+
log!("Setting the RoomsListHeader to offline.");
112+
self.view.view(id!(loading_spinner)).set_visible(cx, false);
113+
self.view.view(id!(synced_icon)).set_visible(cx, false);
114+
self.view.view(id!(offline_icon)).set_visible(cx, true);
115+
enqueue_popup_notification(PopupItem {
116+
message: "Cannot reach the Matrix homeserver. Please check your connection.".into(),
117+
auto_dismissal_duration: None,
118+
kind: PopupKind::Error,
119+
});
120+
}
121+
// For all other states (Idle, Running, etc.), just update without error notification
116122
self.sync_state = new_state.clone();
117123
self.redraw(cx);
118124
}

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)