fix(session): use struct return type and proactive saves

Two fixes for session not persisting:

1. Changed v2_get_all_queue_tracks to return a struct instead of a
   tuple — Tauri IPC serialization of tuples is unreliable.

2. Added proactive session saves instead of relying on async
   beforeunload (which races with window close):
   - Debounced full save on track change (2s after new track starts)
   - Debounced full save on pause
   - Reduced periodic save from 60s to 15s during playback
   - Close handler remains as best-effort backup
This commit is contained in:
vicrodh committed 2026-02-20 20:43:35 -06:00
1 parent aa1aa32f7a
commit 06c0e9735c
2 files changed
+36 -5

No files matched your search

+10 -2
View File
@@ -4360,13 +4360,21 @@ pub async fn v2_get_queue_state(
Ok(bridge.get_queue_state().await)
}
/// Full queue snapshot for session persistence (no caps on track count)
#[derive(serde::Serialize)]
pub struct AllQueueTracksResponse {
pub tracks: Vec<CoreQueueTrack>,
pub current_index: Option<usize>,
}
/// Get all queue tracks and current index (for session persistence, no caps)
#[tauri::command]
pub async fn v2_get_all_queue_tracks(
bridge: State<'_, CoreBridgeState>,
) -> Result<(Vec<CoreQueueTrack>, Option<usize>), RuntimeError> {
) -> Result<AllQueueTracksResponse, RuntimeError> {
let bridge = bridge.get().await;
Ok(bridge.get_all_queue_tracks().await)
let (tracks, current_index) = bridge.get_all_queue_tracks().await;
Ok(AllQueueTracksResponse { tracks, current_index })
}
/// Get currently selected queue track (V2)