Add playlist and favorites commands, update sidebar
Backend: - Add playlist.rs commands: get_user_playlists, get_playlist, search_playlists - Add favorites.rs commands: get_favorites, add_favorite, remove_favorite - Add API client methods: search_playlists, add_favorite, remove_favorite Frontend: - Remove Radio and New from sidebar (no API support) - Sidebar now loads and displays user playlists dynamically - Add playlist and favorites views (placeholder for now) - Pass selectedPlaylistId and onPlaylistSelect to Sidebar
This commit is contained in:
1 parent
dd2600feaa
commit
bda4ea5b76
7 files changed
+276
-50
No files matched your search
@@ -0,0 +1,52 @@
|
||||
//! Playlist-related Tauri commands
|
||||
|
||||
use tauri::State;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::api::client::QobuzClient;
|
||||
use crate::api::models::{Playlist, SearchResultsPage};
|
||||
|
||||
/// Get user's playlists
|
||||
#[tauri::command]
|
||||
pub async fn get_user_playlists(
|
||||
client: State<'_, std::sync::Arc<Mutex<QobuzClient>>>,
|
||||
) -> Result<Vec<Playlist>, String> {
|
||||
log::info!("Command: get_user_playlists");
|
||||
|
||||
let client = client.lock().await;
|
||||
client
|
||||
.get_user_playlists()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to get user playlists: {}", e))
|
||||
}
|
||||
|
||||
/// Get a specific playlist by ID
|
||||
#[tauri::command]
|
||||
pub async fn get_playlist(
|
||||
playlist_id: u64,
|
||||
client: State<'_, std::sync::Arc<Mutex<QobuzClient>>>,
|
||||
) -> Result<Playlist, String> {
|
||||
log::info!("Command: get_playlist {}", playlist_id);
|
||||
|
||||
let client = client.lock().await;
|
||||
client
|
||||
.get_playlist(playlist_id)
|
||||
.await
|
||||
.map_err(|e| format!("Failed to get playlist: {}", e))
|
||||
}
|
||||
|
||||
/// Search playlists
|
||||
#[tauri::command]
|
||||
pub async fn search_playlists(
|
||||
query: String,
|
||||
limit: Option<u32>,
|
||||
client: State<'_, std::sync::Arc<Mutex<QobuzClient>>>,
|
||||
) -> Result<SearchResultsPage<Playlist>, String> {
|
||||
log::info!("Command: search_playlists \"{}\"", query);
|
||||
|
||||
let client = client.lock().await;
|
||||
client
|
||||
.search_playlists(&query, limit.unwrap_or(20))
|
||||
.await
|
||||
.map_err(|e| format!("Failed to search playlists: {}", e))
|
||||
}
|
||||
Reference in new issue
Block a user