refactor(v2): migrate get_artist_detail to v2

Path C: legacy command called client.get_artist_detail with the
hard-coded mobile defaults of limit=1000, offset=0 to populate the
suggestions panel's playlists and tracks_appears_on. No close v2
equivalent existed (v2_get_artist_with_albums uses
extra=albums only), so add v2_get_artist_detail that goes through
QbzCore -> QobuzClient::get_artist_detail directly.

cc
This commit is contained in:
vicrodh committed 2026-04-26 11:45:47 -06:00
1 parent 1dcb7765d3
commit 0bc033b324
5 files changed
+65 -1

No files matched your search

+20
View File
@@ -866,6 +866,26 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
))) )))
} }
/// 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<u32>,
offset: Option<u32>,
) -> Result<Artist, CoreError> {
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) /// Get label page (aggregated: top tracks, releases, playlists, artists)
pub async fn get_label_page(&self, label_id: u64) -> Result<LabelPageData, CoreError> { pub async fn get_label_page(&self, label_id: u64) -> Result<LabelPageData, CoreError> {
let client = self.client.read().await; let client = self.client.read().await;
+30
View File
@@ -427,6 +427,36 @@ pub async fn v2_get_artist_albums(
.map_err(RuntimeError::Internal) .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<u32>,
offset: Option<u32>,
bridge: State<'_, CoreBridgeState>,
runtime: State<'_, RuntimeManagerState>,
) -> Result<Artist, RuntimeError> {
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) /// Get label page (aggregated: top tracks, releases, playlists, artists)
#[tauri::command] #[tauri::command]
#[allow(non_snake_case)] #[allow(non_snake_case)]
+13
View File
@@ -568,6 +568,19 @@ impl CoreBridge {
.map_err(|e| e.to_string()) .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<u32>,
offset: Option<u32>,
) -> Result<Artist, String> {
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) /// Get label page (aggregated: top tracks, releases, playlists, artists)
pub async fn get_label_page(&self, label_id: u64) -> Result<LabelPageData, String> { pub async fn get_label_page(&self, label_id: u64) -> Result<LabelPageData, String> {
self.core self.core
+1
View File
@@ -1704,6 +1704,7 @@ pub fn run() {
commands_v2::v2_get_similar_artists, commands_v2::v2_get_similar_artists,
commands_v2::v2_get_artist_with_albums, commands_v2::v2_get_artist_with_albums,
commands_v2::v2_get_artist_albums, commands_v2::v2_get_artist_albums,
commands_v2::v2_get_artist_detail,
commands_v2::v2_get_label_page, commands_v2::v2_get_label_page,
commands_v2::v2_get_label_explore, commands_v2::v2_get_label_explore,
commands_v2::v2_get_label_albums, commands_v2::v2_get_label_albums,
@@ -110,7 +110,7 @@
try { try {
// Get artist detail which includes playlists and tracks // Get artist detail which includes playlists and tracks
const artist = await invoke<ArtistDetail>('get_artist_detail', { artistId: id }); const artist = await invoke<ArtistDetail>('v2_get_artist_detail', { artistId: id });
loadedArtistId = id; loadedArtistId = id;
// Extract curated playlists (max 2) // Extract curated playlists (max 2)