fix(search): add offset parameter for proper pagination
- Add offset parameter to search_albums, search_tracks, search_artists - Backend now properly passes offset to Qobuz API - Fixes duplicate results when loading more search results
This commit is contained in:
1 parent
5669ae023a
commit
7a53d62341
6 files changed
+503
-11
No files matched your search
@@ -9,11 +9,12 @@ use crate::AppState;
|
||||
pub async fn search_albums(
|
||||
query: String,
|
||||
limit: Option<u32>,
|
||||
offset: Option<u32>,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<SearchResultsPage<Album>, String> {
|
||||
let client = state.client.lock().await;
|
||||
client
|
||||
.search_albums(&query, limit.unwrap_or(20))
|
||||
.search_albums(&query, limit.unwrap_or(20), offset.unwrap_or(0))
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
@@ -22,11 +23,12 @@ pub async fn search_albums(
|
||||
pub async fn search_tracks(
|
||||
query: String,
|
||||
limit: Option<u32>,
|
||||
offset: Option<u32>,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<SearchResultsPage<Track>, String> {
|
||||
let client = state.client.lock().await;
|
||||
client
|
||||
.search_tracks(&query, limit.unwrap_or(20))
|
||||
.search_tracks(&query, limit.unwrap_or(20), offset.unwrap_or(0))
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
@@ -35,11 +37,12 @@ pub async fn search_tracks(
|
||||
pub async fn search_artists(
|
||||
query: String,
|
||||
limit: Option<u32>,
|
||||
offset: Option<u32>,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<SearchResultsPage<Artist>, String> {
|
||||
let client = state.client.lock().await;
|
||||
client
|
||||
.search_artists(&query, limit.unwrap_or(20))
|
||||
.search_artists(&query, limit.unwrap_or(20), offset.unwrap_or(0))
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
@@ -55,3 +58,17 @@ pub async fn get_track(track_id: u64, state: State<'_, AppState>) -> Result<Trac
|
||||
let client = state.client.lock().await;
|
||||
client.get_track(track_id).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Get artist with albums
|
||||
#[tauri::command]
|
||||
pub async fn get_artist(
|
||||
artist_id: u64,
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<Artist, String> {
|
||||
log::info!("Command: get_artist {}", artist_id);
|
||||
let client = state.client.lock().await;
|
||||
client
|
||||
.get_artist(artist_id, true)
|
||||
.await
|
||||
.map_err(|e| e.to_string())
|
||||
}
|
||||
Reference in new issue
Block a user