refactor(v2): migrate get_artist_albums to v2

Path C: legacy command projected `Artist.albums` from
client.get_artist_with_pagination(with_albums=true). The existing
v2_get_artist_with_albums returns the full Artist envelope, so
add a dedicated v2_get_artist_albums in QbzCore that performs the
same projection and exposes only ArtistAlbums to match what the
two callsites destructure.

cc
This commit is contained in:
vicrodh committed 2026-04-26 11:43:23 -06:00
1 parent a127de0f32
commit 1dcb7765d3
6 files changed
+77 -10

No files matched your search

+26 -1
View File
@@ -7,7 +7,7 @@ use std::sync::Arc;
use tokio::sync::RwLock;
use qbz_models::{
Album, Artist, CoreEvent, DiscoverAlbum, DiscoverData, DiscoverPlaylistsResponse,
Album, Artist, ArtistAlbums, CoreEvent, DiscoverAlbum, DiscoverData, DiscoverPlaylistsResponse,
DiscoverResponse, FrontendAdapter, GenreInfo, LabelExploreResponse, LabelGetListResponse,
LabelListPage, LabelPageData, LabelStoryResponse, PageArtistResponse,
Playlist, PlaylistTag, Quality, QueueState, QueueTrack, RepeatMode, SearchResultsPage,
@@ -841,6 +841,31 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
.map_err(CoreError::Api)
}
/// Get an artist's albums collection (paginated `ArtistAlbums` only).
///
/// Equivalent to `get_artist_with_albums` but projects only the `albums`
/// field for callers that don't need the full artist envelope.
pub async fn get_artist_albums(
&self,
artist_id: u64,
limit: Option<u32>,
offset: Option<u32>,
) -> Result<ArtistAlbums, CoreError> {
let client = self.client.read().await;
let client = client.as_ref().ok_or(CoreError::NotInitialized)?;
let artist = client
.get_artist_with_pagination(artist_id, true, limit, offset)
.await
.map_err(CoreError::Api)?;
artist
.albums
.ok_or_else(|| CoreError::Api(qbz_qobuz::ApiError::ApiResponse(
"No albums in artist response".to_string(),
)))
}
/// Get label page (aggregated: top tracks, releases, playlists, artists)
pub async fn get_label_page(&self, label_id: u64) -> Result<LabelPageData, CoreError> {
let client = self.client.read().await;