Make fetch also fetch artist MBID if it is missing #201
@ -6,7 +6,7 @@ use crate::tui::{
|
|||||||
app::{
|
app::{
|
||||||
machine::{App, AppInner, AppMachine},
|
machine::{App, AppInner, AppMachine},
|
||||||
AppPublic, AppPublicAlbumMatches, AppPublicArtistMatches, AppPublicMatches,
|
AppPublic, AppPublicAlbumMatches, AppPublicArtistMatches, AppPublicMatches,
|
||||||
AppPublicMatchesKind, AppState, IAppInteractMatches, WidgetState,
|
AppPublicMatchesInfo, AppState, IAppInteractMatches, WidgetState,
|
||||||
},
|
},
|
||||||
lib::interface::musicbrainz::Match,
|
lib::interface::musicbrainz::Match,
|
||||||
};
|
};
|
||||||
@ -91,11 +91,11 @@ impl AppMatchesInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'app> From<&'app AppMatchesInfo> for AppPublicMatchesKind<'app> {
|
impl<'app> From<&'app AppMatchesInfo> for AppPublicMatchesInfo<'app> {
|
||||||
fn from(value: &'app AppMatchesInfo) -> Self {
|
fn from(value: &'app AppMatchesInfo) -> Self {
|
||||||
match value {
|
match value {
|
||||||
AppMatchesInfo::Artist(a) => AppPublicMatchesKind::Artist(a.into()),
|
AppMatchesInfo::Artist(a) => AppPublicMatchesInfo::Artist(a.into()),
|
||||||
AppMatchesInfo::Album(a) => AppPublicMatchesKind::Album(a.into()),
|
AppMatchesInfo::Album(a) => AppPublicMatchesInfo::Album(a.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,13 +142,13 @@ pub struct AppPublicAlbumMatches<'app> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum AppPublicMatchesKind<'app> {
|
pub enum AppPublicMatchesInfo<'app> {
|
||||||
Artist(AppPublicArtistMatches<'app>),
|
Artist(AppPublicArtistMatches<'app>),
|
||||||
Album(AppPublicAlbumMatches<'app>),
|
Album(AppPublicAlbumMatches<'app>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AppPublicMatches<'app> {
|
pub struct AppPublicMatches<'app> {
|
||||||
pub matches: Option<AppPublicMatchesKind<'app>>,
|
pub matches: Option<AppPublicMatchesInfo<'app>>,
|
||||||
pub state: &'app mut WidgetState,
|
pub state: &'app mut WidgetState,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,17 +165,17 @@ impl<BS, IS, RS, SS, MS, ES, CS> AppState<BS, IS, RS, SS, MS, ES, CS> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
impl<'app> AppPublicMatchesKind<'app> {
|
impl<'app> AppPublicMatchesInfo<'app> {
|
||||||
pub fn artist_ref(&self) -> &AppPublicArtistMatches<'app> {
|
pub fn artist_ref(&self) -> &AppPublicArtistMatches<'app> {
|
||||||
match self {
|
match self {
|
||||||
AppPublicMatchesKind::Artist(m) => m,
|
Self::Artist(m) => m,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn album_ref(&self) -> &AppPublicAlbumMatches<'app> {
|
pub fn album_ref(&self) -> &AppPublicAlbumMatches<'app> {
|
||||||
match self {
|
match self {
|
||||||
AppPublicMatchesKind::Album(m) => m,
|
Self::Album(m) => m,
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use musichoard::collection::{
|
|||||||
track::{TrackFormat, TrackQuality},
|
track::{TrackFormat, TrackQuality},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::tui::{app::AppPublicMatchesKind, lib::interface::musicbrainz::Match};
|
use crate::tui::{app::AppPublicMatchesInfo, lib::interface::musicbrainz::Match};
|
||||||
|
|
||||||
pub struct UiDisplay;
|
pub struct UiDisplay;
|
||||||
|
|
||||||
@ -114,11 +114,11 @@ impl UiDisplay {
|
|||||||
"Matching nothing"
|
"Matching nothing"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn display_matching_info(matches: Option<&AppPublicMatchesKind>) -> String {
|
pub fn display_matching_info(matches: Option<&AppPublicMatchesInfo>) -> String {
|
||||||
match matches.as_ref() {
|
match matches.as_ref() {
|
||||||
Some(kind) => match kind {
|
Some(kind) => match kind {
|
||||||
AppPublicMatchesKind::Artist(m) => UiDisplay::display_artist_matching(m.matching),
|
AppPublicMatchesInfo::Artist(m) => UiDisplay::display_artist_matching(m.matching),
|
||||||
AppPublicMatchesKind::Album(m) => UiDisplay::display_album_matching(m.matching),
|
AppPublicMatchesInfo::Album(m) => UiDisplay::display_album_matching(m.matching),
|
||||||
},
|
},
|
||||||
None => UiDisplay::display_nothing_matching().to_string(),
|
None => UiDisplay::display_nothing_matching().to_string(),
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use musichoard::collection::{album::Album, artist::Artist};
|
|||||||
use ratatui::widgets::{List, ListItem};
|
use ratatui::widgets::{List, ListItem};
|
||||||
|
|
||||||
use crate::tui::{
|
use crate::tui::{
|
||||||
app::{AppPublicMatchesKind, WidgetState},
|
app::{AppPublicMatchesInfo, WidgetState},
|
||||||
lib::interface::musicbrainz::Match,
|
lib::interface::musicbrainz::Match,
|
||||||
ui::display::UiDisplay,
|
ui::display::UiDisplay,
|
||||||
};
|
};
|
||||||
@ -14,11 +14,11 @@ pub struct MatchesState<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> MatchesState<'a, 'b> {
|
impl<'a, 'b> MatchesState<'a, 'b> {
|
||||||
pub fn new(matches: Option<AppPublicMatchesKind>, state: &'b mut WidgetState) -> Self {
|
pub fn new(matches: Option<AppPublicMatchesInfo>, state: &'b mut WidgetState) -> Self {
|
||||||
match matches {
|
match matches {
|
||||||
Some(kind) => match kind {
|
Some(info) => match info {
|
||||||
AppPublicMatchesKind::Artist(m) => Self::artists(m.matching, m.list, state),
|
AppPublicMatchesInfo::Artist(m) => Self::artists(m.matching, m.list, state),
|
||||||
AppPublicMatchesKind::Album(m) => Self::albums(m.matching, m.list, state),
|
AppPublicMatchesInfo::Album(m) => Self::albums(m.matching, m.list, state),
|
||||||
},
|
},
|
||||||
None => Self::empty(state),
|
None => Self::empty(state),
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,10 @@ use ratatui::{layout::Rect, widgets::Paragraph, Frame};
|
|||||||
use musichoard::collection::{album::Album, Collection};
|
use musichoard::collection::{album::Album, Collection};
|
||||||
|
|
||||||
use crate::tui::{
|
use crate::tui::{
|
||||||
app::{AppPublicState, AppState, Category, IAppAccess, Selection, WidgetState},
|
app::{
|
||||||
|
AppPublicMatchesInfo, AppPublicState, AppState, Category, IAppAccess, Selection,
|
||||||
|
WidgetState,
|
||||||
|
},
|
||||||
ui::{
|
ui::{
|
||||||
browse::{
|
browse::{
|
||||||
AlbumArea, AlbumState, ArtistArea, ArtistState, FrameArea, TrackArea, TrackState,
|
AlbumArea, AlbumState, ArtistArea, ArtistState, FrameArea, TrackArea, TrackState,
|
||||||
@ -30,8 +33,6 @@ use crate::tui::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::app::AppPublicMatchesKind;
|
|
||||||
|
|
||||||
pub trait IUi {
|
pub trait IUi {
|
||||||
fn render<APP: IAppAccess>(app: &mut APP, frame: &mut Frame);
|
fn render<APP: IAppAccess>(app: &mut APP, frame: &mut Frame);
|
||||||
}
|
}
|
||||||
@ -134,7 +135,7 @@ impl Ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn render_matches_overlay(
|
fn render_matches_overlay(
|
||||||
matches: Option<AppPublicMatchesKind>,
|
matches: Option<AppPublicMatchesInfo>,
|
||||||
state: &mut WidgetState,
|
state: &mut WidgetState,
|
||||||
frame: &mut Frame,
|
frame: &mut Frame,
|
||||||
) {
|
) {
|
||||||
@ -213,8 +214,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'app> AppPublicMatchesKind<'app> {
|
impl<'app> AppPublicMatchesInfo<'app> {
|
||||||
fn get(&self) -> AppPublicMatchesKind<'app> {
|
fn get(&self) -> AppPublicMatchesInfo<'app> {
|
||||||
match self {
|
match self {
|
||||||
Self::Artist(a) => Self::Artist(a.get()),
|
Self::Artist(a) => Self::Artist(a.get()),
|
||||||
Self::Album(a) => Self::Album(a.get()),
|
Self::Album(a) => Self::Album(a.get()),
|
||||||
@ -259,15 +260,15 @@ mod tests {
|
|||||||
fn artist_matches<'app>(
|
fn artist_matches<'app>(
|
||||||
matching: &'app Artist,
|
matching: &'app Artist,
|
||||||
list: &'app [Match<Artist>],
|
list: &'app [Match<Artist>],
|
||||||
) -> AppPublicMatchesKind<'app> {
|
) -> AppPublicMatchesInfo<'app> {
|
||||||
AppPublicMatchesKind::Artist(AppPublicArtistMatches { matching, list })
|
AppPublicMatchesInfo::Artist(AppPublicArtistMatches { matching, list })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn album_matches<'app>(
|
fn album_matches<'app>(
|
||||||
matching: &'app Album,
|
matching: &'app Album,
|
||||||
list: &'app [Match<Album>],
|
list: &'app [Match<Album>],
|
||||||
) -> AppPublicMatchesKind<'app> {
|
) -> AppPublicMatchesInfo<'app> {
|
||||||
AppPublicMatchesKind::Album(AppPublicAlbumMatches { matching, list })
|
AppPublicMatchesInfo::Album(AppPublicAlbumMatches { matching, list })
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_test_suite(collection: &Collection, selection: &mut Selection) {
|
fn draw_test_suite(collection: &Collection, selection: &mut Selection) {
|
||||||
|
Loading…
Reference in New Issue
Block a user