fix(v2-commands): return SearchResultsPage for search commands
Update search commands to return full SearchResultsPage<T> with pagination info instead of just Vec<T>. This makes V2 commands compatible with the frontend's expected response format.
This commit is contained in:
1 parent
8ed8f02fcd
commit
b930fa11ba
3 files changed
+13
-15
No files matched your search
@@ -7,7 +7,8 @@ use std::sync::Arc;
|
|||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use qbz_models::{
|
use qbz_models::{
|
||||||
Album, Artist, CoreEvent, FrontendAdapter, QueueState, RepeatMode, Track, UserSession,
|
Album, Artist, CoreEvent, FrontendAdapter, QueueState, RepeatMode, SearchResultsPage, Track,
|
||||||
|
UserSession,
|
||||||
};
|
};
|
||||||
use qbz_player::QueueManager;
|
use qbz_player::QueueManager;
|
||||||
use qbz_qobuz::QobuzClient;
|
use qbz_qobuz::QobuzClient;
|
||||||
@@ -156,14 +157,13 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
|
|||||||
query: &str,
|
query: &str,
|
||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
) -> Result<Vec<Album>, CoreError> {
|
) -> Result<SearchResultsPage<Album>, CoreError> {
|
||||||
let client = self.client.read().await;
|
let client = self.client.read().await;
|
||||||
let client = client.as_ref().ok_or(CoreError::NotInitialized)?;
|
let client = client.as_ref().ok_or(CoreError::NotInitialized)?;
|
||||||
|
|
||||||
client
|
client
|
||||||
.search_albums(query, limit, offset, None)
|
.search_albums(query, limit, offset, None)
|
||||||
.await
|
.await
|
||||||
.map(|r| r.items)
|
|
||||||
.map_err(CoreError::Api)
|
.map_err(CoreError::Api)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,14 +173,13 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
|
|||||||
query: &str,
|
query: &str,
|
||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
) -> Result<Vec<Track>, CoreError> {
|
) -> Result<SearchResultsPage<Track>, CoreError> {
|
||||||
let client = self.client.read().await;
|
let client = self.client.read().await;
|
||||||
let client = client.as_ref().ok_or(CoreError::NotInitialized)?;
|
let client = client.as_ref().ok_or(CoreError::NotInitialized)?;
|
||||||
|
|
||||||
client
|
client
|
||||||
.search_tracks(query, limit, offset, None)
|
.search_tracks(query, limit, offset, None)
|
||||||
.await
|
.await
|
||||||
.map(|r| r.items)
|
|
||||||
.map_err(CoreError::Api)
|
.map_err(CoreError::Api)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,14 +189,13 @@ impl<A: FrontendAdapter + Send + Sync + 'static> QbzCore<A> {
|
|||||||
query: &str,
|
query: &str,
|
||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
) -> Result<Vec<Artist>, CoreError> {
|
) -> Result<SearchResultsPage<Artist>, CoreError> {
|
||||||
let client = self.client.read().await;
|
let client = self.client.read().await;
|
||||||
let client = client.as_ref().ok_or(CoreError::NotInitialized)?;
|
let client = client.as_ref().ok_or(CoreError::NotInitialized)?;
|
||||||
|
|
||||||
client
|
client
|
||||||
.search_artists(query, limit, offset, None)
|
.search_artists(query, limit, offset, None)
|
||||||
.await
|
.await
|
||||||
.map(|r| r.items)
|
|
||||||
.map_err(CoreError::Api)
|
.map_err(CoreError::Api)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
use tauri::State;
|
use tauri::State;
|
||||||
|
|
||||||
use qbz_models::{Album, Artist, QueueState, RepeatMode, Track, UserSession};
|
use qbz_models::{Album, Artist, QueueState, RepeatMode, SearchResultsPage, Track, UserSession};
|
||||||
|
|
||||||
use crate::core_bridge::CoreBridgeState;
|
use crate::core_bridge::CoreBridgeState;
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ pub async fn v2_search_albums(
|
|||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
bridge: State<'_, CoreBridgeState>,
|
bridge: State<'_, CoreBridgeState>,
|
||||||
) -> Result<Vec<Album>, String> {
|
) -> Result<SearchResultsPage<Album>, String> {
|
||||||
let bridge = bridge.get().await;
|
let bridge = bridge.get().await;
|
||||||
bridge.search_albums(&query, limit, offset).await
|
bridge.search_albums(&query, limit, offset).await
|
||||||
}
|
}
|
||||||
@@ -102,7 +102,7 @@ pub async fn v2_search_tracks(
|
|||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
bridge: State<'_, CoreBridgeState>,
|
bridge: State<'_, CoreBridgeState>,
|
||||||
) -> Result<Vec<Track>, String> {
|
) -> Result<SearchResultsPage<Track>, String> {
|
||||||
let bridge = bridge.get().await;
|
let bridge = bridge.get().await;
|
||||||
bridge.search_tracks(&query, limit, offset).await
|
bridge.search_tracks(&query, limit, offset).await
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ pub async fn v2_search_artists(
|
|||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
bridge: State<'_, CoreBridgeState>,
|
bridge: State<'_, CoreBridgeState>,
|
||||||
) -> Result<Vec<Artist>, String> {
|
) -> Result<SearchResultsPage<Artist>, String> {
|
||||||
let bridge = bridge.get().await;
|
let bridge = bridge.get().await;
|
||||||
bridge.search_artists(&query, limit, offset).await
|
bridge.search_artists(&query, limit, offset).await
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use std::sync::Arc;
|
|||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
|
|
||||||
use qbz_core::QbzCore;
|
use qbz_core::QbzCore;
|
||||||
use qbz_models::{Album, Artist, QueueState, RepeatMode, Track, UserSession};
|
use qbz_models::{Album, Artist, QueueState, RepeatMode, SearchResultsPage, Track, UserSession};
|
||||||
|
|
||||||
use crate::tauri_adapter::TauriAdapter;
|
use crate::tauri_adapter::TauriAdapter;
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ impl CoreBridge {
|
|||||||
query: &str,
|
query: &str,
|
||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
) -> Result<Vec<Album>, String> {
|
) -> Result<SearchResultsPage<Album>, String> {
|
||||||
self.core
|
self.core
|
||||||
.search_albums(query, limit, offset)
|
.search_albums(query, limit, offset)
|
||||||
.await
|
.await
|
||||||
@@ -96,7 +96,7 @@ impl CoreBridge {
|
|||||||
query: &str,
|
query: &str,
|
||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
) -> Result<Vec<Track>, String> {
|
) -> Result<SearchResultsPage<Track>, String> {
|
||||||
self.core
|
self.core
|
||||||
.search_tracks(query, limit, offset)
|
.search_tracks(query, limit, offset)
|
||||||
.await
|
.await
|
||||||
@@ -109,7 +109,7 @@ impl CoreBridge {
|
|||||||
query: &str,
|
query: &str,
|
||||||
limit: u32,
|
limit: u32,
|
||||||
offset: u32,
|
offset: u32,
|
||||||
) -> Result<Vec<Artist>, String> {
|
) -> Result<SearchResultsPage<Artist>, String> {
|
||||||
self.core
|
self.core
|
||||||
.search_artists(query, limit, offset)
|
.search_artists(query, limit, offset)
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in new issue
Block a user