Test listing artists
parent
09ccbe9cd4
commit
7ccf7f48a9
|
@ -15,6 +15,8 @@ A custom configuration file can be passed as an argument, and arguments will ove
|
|||
|
||||
`s` - Stop
|
||||
|
||||
`Tab` - Swap through search sections
|
||||
|
||||
`i` - Insert mode (search)
|
||||
|
||||
`<esc>` - Return to normal mode
|
||||
|
|
|
@ -25,7 +25,7 @@ use paris::{error, info};
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
mod structs;
|
||||
use structs::{App, InputMode, StatefulList, Blocks, SongList, Search};
|
||||
use structs::{App, InputMode, StatefulList, Blocks, SongList, Search, ArtistList};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
struct Config {
|
||||
|
@ -270,6 +270,8 @@ fn run_app<B: Backend>(
|
|||
None => "",
|
||||
};
|
||||
app.last_songs = app.songs.mpd_search(&mut app.mpd_client, last_results.to_string(), (0,50));
|
||||
app.last_artists = app.artists.mpd_search(&mut app.mpd_client, last_results.to_string(), (0,50));
|
||||
app.artists = ArtistList::with_items(app.last_artists.clone());
|
||||
app.songs = SongList::with_items(app.last_songs.clone());
|
||||
app.input_mode = InputMode::Normal;
|
||||
}
|
||||
|
@ -277,12 +279,16 @@ fn run_app<B: Backend>(
|
|||
app.input.push(c);
|
||||
let results = app.input.clone();
|
||||
app.last_songs = app.songs.mpd_search(&mut app.mpd_client, results.to_string(), (0,50));
|
||||
app.last_artists = app.artists.mpd_search(&mut app.mpd_client, results.to_string(), (0,50));
|
||||
app.artists = ArtistList::with_items(app.last_artists.clone());
|
||||
app.songs = SongList::with_items(app.last_songs.clone());
|
||||
}
|
||||
KeyCode::Backspace => {
|
||||
app.input.pop();
|
||||
let results = app.input.clone();
|
||||
app.last_songs = app.songs.mpd_search(&mut app.mpd_client, results.to_string(), (0,50));
|
||||
app.last_artists = app.artists.mpd_search(&mut app.mpd_client, results.to_string(), (0,50));
|
||||
app.artists = ArtistList::with_items(app.last_artists.clone());
|
||||
app.songs = SongList::with_items(app.last_songs.clone());
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -118,6 +118,31 @@ pub struct ArtistList {
|
|||
pub items: Vec<(String, usize)>,
|
||||
}
|
||||
|
||||
impl Search for ArtistList {
|
||||
type Item = (String, usize);
|
||||
|
||||
fn mpd_search(&self, client: &mut Client, query: String, range: (u32, u32)) -> Vec<Self::Item> {
|
||||
match client.list(&Term::Tag(std::borrow::Cow::Borrowed("AlbumArtist")), &Query::new().and(Term::Any, query)) {
|
||||
Ok(s) => {
|
||||
let mut results: Vec<(String, usize)> = vec![];
|
||||
let mut x = 0;
|
||||
for i in s {
|
||||
error!("{}", i);
|
||||
results.push((i, x));
|
||||
x += 1;
|
||||
}
|
||||
results
|
||||
},
|
||||
Err(e) => vec![("<no results>".to_string(), 0)],
|
||||
}
|
||||
}
|
||||
|
||||
fn fuzzy_search(&self, client: &Client, query: String, range: (u32, u32)) -> Vec<Self::Item> {
|
||||
error!("Unimplemented!");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
impl StatefulList for ArtistList {
|
||||
type Item = (String, usize);
|
||||
type List = ArtistList;
|
||||
|
|
Loading…
Reference in New Issue