Revert "switch to rspotify's new universal search method"

This reverts commit e55d0ac7ba.
This commit is contained in:
Henrik Friedrichsen
2020-06-25 21:05:49 +02:00
parent 0f08a56f90
commit 03045ba256
4 changed files with 31 additions and 37 deletions

View File

@@ -22,8 +22,6 @@ use crate::track::Track;
use crate::traits::{ListItem, ViewExt};
use crate::ui::listview::{ListView, Pagination};
use crate::ui::tabview::TabView;
use rspotify::model::search::SearchResult;
use rspotify::senum::SearchType;
pub struct SearchView {
results_tracks: Arc<RwLock<Vec<Track>>>,
@@ -131,10 +129,8 @@ impl SearchView {
offset: usize,
append: bool,
) -> u32 {
if let Some(SearchResult::Tracks(results)) =
spotify.search(SearchType::Track, &query, 50, offset as u32)
{
let mut t = results.items.iter().map(|ft| ft.into()).collect();
if let Some(results) = spotify.search_track(&query, 50, offset as u32) {
let mut t = results.tracks.items.iter().map(|ft| ft.into()).collect();
let mut r = tracks.write().unwrap();
if append {
@@ -142,7 +138,7 @@ impl SearchView {
} else {
*r = t;
}
return results.total;
return results.tracks.total;
}
0
}
@@ -170,10 +166,8 @@ impl SearchView {
offset: usize,
append: bool,
) -> u32 {
if let Some(SearchResult::Albums(results)) =
spotify.search(SearchType::Album, &query, 50, offset as u32)
{
let mut a = results.items.iter().map(|sa| sa.into()).collect();
if let Some(results) = spotify.search_album(&query, 50, offset as u32) {
let mut a = results.albums.items.iter().map(|sa| sa.into()).collect();
let mut r = albums.write().unwrap();
if append {
@@ -181,7 +175,7 @@ impl SearchView {
} else {
*r = a;
}
return results.total;
return results.albums.total;
}
0
}
@@ -209,10 +203,8 @@ impl SearchView {
offset: usize,
append: bool,
) -> u32 {
if let Some(SearchResult::Artists(results)) =
spotify.search(SearchType::Artist, &query, 50, offset as u32)
{
let mut a = results.items.iter().map(|fa| fa.into()).collect();
if let Some(results) = spotify.search_artist(&query, 50, offset as u32) {
let mut a = results.artists.items.iter().map(|fa| fa.into()).collect();
let mut r = artists.write().unwrap();
if append {
@@ -220,7 +212,7 @@ impl SearchView {
} else {
*r = a;
}
return results.total;
return results.artists.total;
}
0
}
@@ -248,10 +240,8 @@ impl SearchView {
offset: usize,
append: bool,
) -> u32 {
if let Some(SearchResult::Playlists(results)) =
spotify.search(SearchType::Playlist, &query, 50, offset as u32)
{
let mut pls = results.items.iter().map(|sp| sp.into()).collect();
if let Some(results) = spotify.search_playlist(&query, 50, offset as u32) {
let mut pls = results.playlists.items.iter().map(|sp| sp.into()).collect();
let mut r = playlists.write().unwrap();
if append {
@@ -259,7 +249,7 @@ impl SearchView {
} else {
*r = pls;
}
return results.total;
return results.playlists.total;
}
0
}