Add offline mode track handling for playlists and queue
- Add batch check command for track local status in Rust - Show unavailable tracks with grayed-out visual state in PlaylistDetailView - Disable interactions for unavailable tracks (click, menu, play) - Add WifiOff indicator for unavailable tracks - Update QueuePanel to show unavailable track styling - Implement auto-skip for unavailable tracks during playback - Add offline mode sync to queue store - Add offline-specific filter states to PlaylistManager: - Available Offline - Partially Available - Not Available Offline (view-only) - Disable edit/drag for unavailable playlists in PlaylistManager - Add i18n strings for offline states (en/es)
This commit is contained in:
1 parent
6180fea08e
commit
6f3bcfe1cb
10 files changed
+490
-74
No files matched your search
@@ -1224,6 +1224,21 @@ pub async fn playlist_get_local_track_id(
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Batch check which tracks have local copies (for offline mode)
|
||||
/// Returns a list of track IDs that have local versions
|
||||
#[tauri::command]
|
||||
pub async fn playlist_get_tracks_with_local_copies(
|
||||
track_ids: Vec<u64>,
|
||||
state: State<'_, LibraryState>,
|
||||
) -> Result<Vec<u64>, String> {
|
||||
let db = state.db.lock().await;
|
||||
|
||||
let local_ids = db.get_tracks_with_local_copies(&track_ids)
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
Ok(local_ids.into_iter().collect())
|
||||
}
|
||||
|
||||
/// Get playlists that have local content (for offline mode filtering)
|
||||
#[tauri::command]
|
||||
pub async fn playlist_get_offline_available(
|
||||
|
||||
@@ -1713,6 +1713,48 @@ impl LibraryDatabase {
|
||||
.map_err(|e| LibraryError::Database(e.to_string()))
|
||||
}
|
||||
|
||||
/// Batch check which track IDs have local copies
|
||||
/// Returns a set of Qobuz track IDs that have local versions
|
||||
pub fn get_tracks_with_local_copies(&self, qobuz_track_ids: &[u64]) -> Result<std::collections::HashSet<u64>, LibraryError> {
|
||||
use std::collections::HashSet;
|
||||
|
||||
if qobuz_track_ids.is_empty() {
|
||||
return Ok(HashSet::new());
|
||||
}
|
||||
|
||||
// Build placeholders for IN clause
|
||||
let placeholders: Vec<String> = (1..=qobuz_track_ids.len())
|
||||
.map(|i| format!("?{}", i))
|
||||
.collect();
|
||||
let placeholders_str = placeholders.join(",");
|
||||
|
||||
let query = format!(
|
||||
"SELECT DISTINCT qobuz_track_id FROM local_tracks WHERE qobuz_track_id IN ({})",
|
||||
placeholders_str
|
||||
);
|
||||
|
||||
let mut stmt = self.conn.prepare(&query)
|
||||
.map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||
|
||||
let params: Vec<rusqlite::types::Value> = qobuz_track_ids
|
||||
.iter()
|
||||
.map(|&id| rusqlite::types::Value::Integer(id as i64))
|
||||
.collect();
|
||||
|
||||
let rows = stmt.query_map(rusqlite::params_from_iter(params.iter()), |row| {
|
||||
row.get::<_, i64>(0)
|
||||
}).map_err(|e| LibraryError::Database(e.to_string()))?;
|
||||
|
||||
let mut result = HashSet::new();
|
||||
for row in rows {
|
||||
if let Ok(id) = row {
|
||||
result.insert(id as u64);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Update the has_local_content status for a playlist
|
||||
pub fn update_playlist_local_content_status(
|
||||
&self,
|
||||
|
||||
Reference in new issue
Block a user