Add a popup window for artist metadata #70
@ -414,8 +414,8 @@ impl<'a> ArtistOverlay<'a> {
|
||||
}
|
||||
|
||||
fn opt_vec_to_string<U: IUrl>(opt_vec: Option<&Vec<U>>, indent: &str) -> String {
|
||||
match opt_vec {
|
||||
Some(vec) => {
|
||||
opt_vec
|
||||
.map(|vec| {
|
||||
if vec.len() < 2 {
|
||||
vec.get(0).map(|item| item.url()).unwrap_or("").to_string()
|
||||
} else {
|
||||
@ -427,9 +427,8 @@ impl<'a> ArtistOverlay<'a> {
|
||||
.join(&indent);
|
||||
format!("{indent}{list}")
|
||||
}
|
||||
}
|
||||
None => String::from(""),
|
||||
}
|
||||
})
|
||||
.unwrap_or_else(|| String::from(""))
|
||||
}
|
||||
|
||||
fn new(artists: &'a [Artist], state: &ListState) -> ArtistOverlay<'a> {
|
||||
@ -686,7 +685,7 @@ impl<MH: IMusicHoard> Ui<MH> {
|
||||
let artists = self.music_hoard.get_collection();
|
||||
let artist_selection = &mut self.selection.artist;
|
||||
|
||||
let artist_overlay = ArtistOverlay::new(&artists, &artist_selection.state);
|
||||
let artist_overlay = ArtistOverlay::new(artists, &artist_selection.state);
|
||||
Self::render_overlay_widget("Artist", artist_overlay.properties, areas.artist, frame);
|
||||
}
|
||||
}
|
||||
@ -1171,6 +1170,27 @@ mod tests {
|
||||
terminal.draw(|frame| ui.render(frame)).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overlay() {
|
||||
let mut terminal = terminal();
|
||||
let mut ui = ui(COLLECTION.to_owned());
|
||||
|
||||
terminal.draw(|frame| ui.render(frame)).unwrap();
|
||||
|
||||
ui.toggle_overlay();
|
||||
|
||||
terminal.draw(|frame| ui.render(frame)).unwrap();
|
||||
|
||||
// Change the artist (which has a multi-link entry).
|
||||
ui.increment_selection();
|
||||
|
||||
terminal.draw(|frame| ui.render(frame)).unwrap();
|
||||
|
||||
ui.toggle_overlay();
|
||||
|
||||
terminal.draw(|frame| ui.render(frame)).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn errors() {
|
||||
let ui_err: UiError = musichoard::Error::DatabaseError(String::from("get rekt")).into();
|
||||
|
Loading…
Reference in New Issue
Block a user