diff --git a/crates/qbz-core/src/core.rs b/crates/qbz-core/src/core.rs index 9f722541e..7e692f674 100644 --- a/crates/qbz-core/src/core.rs +++ b/crates/qbz-core/src/core.rs @@ -866,6 +866,26 @@ impl QbzCore { ))) } + /// Get artist detail with albums, playlists and appears-on tracks. + /// + /// Backs the suggestions panel: requests `extra=albums,tracks_appears_on,playlists` + /// from `/artist/get` so callers can read `playlists` and `tracks_appears_on` + /// without a second round-trip. + pub async fn get_artist_detail( + &self, + artist_id: u64, + limit: Option, + offset: Option, + ) -> Result { + let client = self.client.read().await; + let client = client.as_ref().ok_or(CoreError::NotInitialized)?; + + client + .get_artist_detail(artist_id, limit, offset) + .await + .map_err(CoreError::Api) + } + /// Get label page (aggregated: top tracks, releases, playlists, artists) pub async fn get_label_page(&self, label_id: u64) -> Result { let client = self.client.read().await; diff --git a/src-tauri/src/commands_v2/catalog.rs b/src-tauri/src/commands_v2/catalog.rs index 17d3baf1a..f33375879 100644 --- a/src-tauri/src/commands_v2/catalog.rs +++ b/src-tauri/src/commands_v2/catalog.rs @@ -427,6 +427,36 @@ pub async fn v2_get_artist_albums( .map_err(RuntimeError::Internal) } +/// Get artist detail with albums, playlists and appears-on tracks (V2 - uses QbzCore). +#[tauri::command] +#[allow(non_snake_case)] +pub async fn v2_get_artist_detail( + artistId: u64, + limit: Option, + offset: Option, + bridge: State<'_, CoreBridgeState>, + runtime: State<'_, RuntimeManagerState>, +) -> Result { + runtime + .manager() + .check_requirements(CommandRequirement::RequiresCoreBridgeAuth) + .await?; + + let limit = limit.or(Some(1000)); + let offset = offset.or(Some(0)); + log::info!( + "[V2] get_artist_detail: {} limit={:?} offset={:?}", + artistId, + limit, + offset + ); + let bridge = bridge.get().await; + bridge + .get_artist_detail(artistId, limit, offset) + .await + .map_err(RuntimeError::Internal) +} + /// Get label page (aggregated: top tracks, releases, playlists, artists) #[tauri::command] #[allow(non_snake_case)] diff --git a/src-tauri/src/core_bridge.rs b/src-tauri/src/core_bridge.rs index 1bf7a78eb..66158957b 100644 --- a/src-tauri/src/core_bridge.rs +++ b/src-tauri/src/core_bridge.rs @@ -568,6 +568,19 @@ impl CoreBridge { .map_err(|e| e.to_string()) } + /// Get artist detail (albums, playlists, appears-on tracks). + pub async fn get_artist_detail( + &self, + artist_id: u64, + limit: Option, + offset: Option, + ) -> Result { + self.core + .get_artist_detail(artist_id, limit, offset) + .await + .map_err(|e| e.to_string()) + } + /// Get label page (aggregated: top tracks, releases, playlists, artists) pub async fn get_label_page(&self, label_id: u64) -> Result { self.core diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index d16b5885f..f2adc5f5b 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1704,6 +1704,7 @@ pub fn run() { commands_v2::v2_get_similar_artists, commands_v2::v2_get_artist_with_albums, commands_v2::v2_get_artist_albums, + commands_v2::v2_get_artist_detail, commands_v2::v2_get_label_page, commands_v2::v2_get_label_explore, commands_v2::v2_get_label_albums, diff --git a/src/lib/components/immersive/panels/SuggestionsPanel.svelte b/src/lib/components/immersive/panels/SuggestionsPanel.svelte index 70c70893c..82c472052 100644 --- a/src/lib/components/immersive/panels/SuggestionsPanel.svelte +++ b/src/lib/components/immersive/panels/SuggestionsPanel.svelte @@ -110,7 +110,7 @@ try { // Get artist detail which includes playlists and tracks - const artist = await invoke('get_artist_detail', { artistId: id }); + const artist = await invoke('v2_get_artist_detail', { artistId: id }); loadedArtistId = id; // Extract curated playlists (max 2)