fix: defer visualizer, remote control, and last.fm to post-login
Visualizer FFT thread, remote control API server, and Last.fm session
restore were all initializing before user session activation, causing
errors ("No active session") and wasting resources.
Move all three to run after activate_user_session:
- Visualizer: add started guard to prevent double-start
- Remote control: sync_server now has per-user settings available
- Last.fm: restoreLastfmSession moved from bootstrapApp to handleLoginSuccess
This commit is contained in:
1 parent
ff8c69f573
commit
aef4285fd9
5 files changed
+32
-17
No files matched your search
@@ -6,7 +6,7 @@
|
||||
|
||||
use std::path::Path;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tauri::State;
|
||||
use tauri::{Manager, State};
|
||||
|
||||
use crate::api_cache::ApiCacheState;
|
||||
use crate::artist_blacklist::BlacklistState;
|
||||
@@ -69,6 +69,7 @@ pub fn get_last_user_id() -> Option<u64> {
|
||||
/// and cache stores at `~/.cache/qbz/users/{user_id}/`.
|
||||
#[tauri::command]
|
||||
pub async fn activate_user_session(
|
||||
app: tauri::AppHandle,
|
||||
user_id: u64,
|
||||
user_paths: State<'_, UserDataPaths>,
|
||||
session_store: State<'_, SessionStoreState>,
|
||||
@@ -180,6 +181,19 @@ pub async fn activate_user_session(
|
||||
log::warn!("Failed to save last_user_id: {}", e);
|
||||
}
|
||||
|
||||
// Start visualizer FFT thread (idempotent — only starts once even if called twice)
|
||||
app.state::<crate::AppState>()
|
||||
.visualizer
|
||||
.start(app.clone());
|
||||
|
||||
// Start remote control API server if enabled in user settings
|
||||
let app_clone = app.clone();
|
||||
tauri::async_runtime::spawn(async move {
|
||||
if let Err(e) = crate::api_server::sync_server(&app_clone).await {
|
||||
log::error!("Remote control API init failed: {}", e);
|
||||
}
|
||||
});
|
||||
|
||||
log::info!("User session activated for user_id={}", user_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user