fix: logout spinner hang and last_user_id preservation
Two bugs: 1. mainContentEl teardown crash on logout — the $effect cleanup used non-null assertion (!) on an element that becomes null when the DOM is destroyed during logout. Changed to optional chaining (?.). This TypeError was blocking the render, causing the spinner to hang instead of showing the login form. 2. deactivate_session was clearing last_user_id, which broke offline mode after logout. The user's data stays on disk — only factory reset should clear the last_user_id marker. cc
This commit is contained in:
2 files changed
+4
-3
No files matched your search
@@ -315,9 +315,10 @@ pub async fn deactivate_session(app: &tauri::AppHandle) -> Result<(), String> {
|
||||
crate::commands::user_session::teardown_type_alias_state(&*subscription_state);
|
||||
crate::commands::user_session::teardown_type_alias_state(&*download_settings);
|
||||
|
||||
// Clear the active user and persisted last_user_id
|
||||
// Clear the active user but KEEP last_user_id on disk.
|
||||
// Offline mode needs it to load the user's library and settings
|
||||
// even after logout.
|
||||
user_paths.clear_user();
|
||||
UserDataPaths::clear_last_user_id();
|
||||
|
||||
// Update runtime state - clear BOTH auth and session
|
||||
runtime_manager.manager().set_legacy_auth(false, None).await;
|
||||
|
||||
@@ -530,7 +530,7 @@
|
||||
}
|
||||
};
|
||||
mainContentEl.addEventListener('scroll', handler, true);
|
||||
return () => mainContentEl!.removeEventListener('scroll', handler, true);
|
||||
return () => mainContentEl?.removeEventListener('scroll', handler, true);
|
||||
});
|
||||
|
||||
// Reset scroll state on view or item change (but not on back/forward — that restores saved position)
|
||||
|
||||
Reference in new issue
Block a user