diff --git a/src/tui/app/machine/matches.rs b/src/tui/app/machine/matches.rs index c92f9fd..6d028e5 100644 --- a/src/tui/app/machine/matches.rs +++ b/src/tui/app/machine/matches.rs @@ -6,7 +6,7 @@ use crate::tui::{ app::{ machine::{App, AppInner, AppMachine}, AppPublic, AppPublicAlbumMatches, AppPublicArtistMatches, AppPublicMatches, - AppPublicMatchesKind, AppState, IAppInteractMatches, WidgetState, + AppPublicMatchesInfo, AppState, IAppInteractMatches, WidgetState, }, 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 { match value { - AppMatchesInfo::Artist(a) => AppPublicMatchesKind::Artist(a.into()), - AppMatchesInfo::Album(a) => AppPublicMatchesKind::Album(a.into()), + AppMatchesInfo::Artist(a) => AppPublicMatchesInfo::Artist(a.into()), + AppMatchesInfo::Album(a) => AppPublicMatchesInfo::Album(a.into()), } } } diff --git a/src/tui/app/mod.rs b/src/tui/app/mod.rs index a7fd5d5..b938247 100644 --- a/src/tui/app/mod.rs +++ b/src/tui/app/mod.rs @@ -142,13 +142,13 @@ pub struct AppPublicAlbumMatches<'app> { } #[derive(Debug, PartialEq, Eq)] -pub enum AppPublicMatchesKind<'app> { +pub enum AppPublicMatchesInfo<'app> { Artist(AppPublicArtistMatches<'app>), Album(AppPublicAlbumMatches<'app>), } pub struct AppPublicMatches<'app> { - pub matches: Option>, + pub matches: Option>, pub state: &'app mut WidgetState, } @@ -165,17 +165,17 @@ impl AppState { mod tests { use super::*; - impl<'app> AppPublicMatchesKind<'app> { + impl<'app> AppPublicMatchesInfo<'app> { pub fn artist_ref(&self) -> &AppPublicArtistMatches<'app> { match self { - AppPublicMatchesKind::Artist(m) => m, + Self::Artist(m) => m, _ => panic!(), } } pub fn album_ref(&self) -> &AppPublicAlbumMatches<'app> { match self { - AppPublicMatchesKind::Album(m) => m, + Self::Album(m) => m, _ => panic!(), } } diff --git a/src/tui/ui/display.rs b/src/tui/ui/display.rs index de7b959..f566c56 100644 --- a/src/tui/ui/display.rs +++ b/src/tui/ui/display.rs @@ -4,7 +4,7 @@ use musichoard::collection::{ track::{TrackFormat, TrackQuality}, }; -use crate::tui::{app::AppPublicMatchesKind, lib::interface::musicbrainz::Match}; +use crate::tui::{app::AppPublicMatchesInfo, lib::interface::musicbrainz::Match}; pub struct UiDisplay; @@ -114,11 +114,11 @@ impl UiDisplay { "Matching nothing" } - pub fn display_matching_info(matches: Option<&AppPublicMatchesKind>) -> String { + pub fn display_matching_info(matches: Option<&AppPublicMatchesInfo>) -> String { match matches.as_ref() { Some(kind) => match kind { - AppPublicMatchesKind::Artist(m) => UiDisplay::display_artist_matching(m.matching), - AppPublicMatchesKind::Album(m) => UiDisplay::display_album_matching(m.matching), + AppPublicMatchesInfo::Artist(m) => UiDisplay::display_artist_matching(m.matching), + AppPublicMatchesInfo::Album(m) => UiDisplay::display_album_matching(m.matching), }, None => UiDisplay::display_nothing_matching().to_string(), } diff --git a/src/tui/ui/matches.rs b/src/tui/ui/matches.rs index 274422f..301ed17 100644 --- a/src/tui/ui/matches.rs +++ b/src/tui/ui/matches.rs @@ -2,7 +2,7 @@ use musichoard::collection::{album::Album, artist::Artist}; use ratatui::widgets::{List, ListItem}; use crate::tui::{ - app::{AppPublicMatchesKind, WidgetState}, + app::{AppPublicMatchesInfo, WidgetState}, lib::interface::musicbrainz::Match, ui::display::UiDisplay, }; @@ -14,11 +14,11 @@ pub struct MatchesState<'a, 'b> { } impl<'a, 'b> MatchesState<'a, 'b> { - pub fn new(matches: Option, state: &'b mut WidgetState) -> Self { + pub fn new(matches: Option, state: &'b mut WidgetState) -> Self { match matches { - Some(kind) => match kind { - AppPublicMatchesKind::Artist(m) => Self::artists(m.matching, m.list, state), - AppPublicMatchesKind::Album(m) => Self::albums(m.matching, m.list, state), + Some(info) => match info { + AppPublicMatchesInfo::Artist(m) => Self::artists(m.matching, m.list, state), + AppPublicMatchesInfo::Album(m) => Self::albums(m.matching, m.list, state), }, None => Self::empty(state), } diff --git a/src/tui/ui/mod.rs b/src/tui/ui/mod.rs index 5f59f5c..47b2939 100644 --- a/src/tui/ui/mod.rs +++ b/src/tui/ui/mod.rs @@ -14,7 +14,10 @@ use ratatui::{layout::Rect, widgets::Paragraph, Frame}; use musichoard::collection::{album::Album, Collection}; use crate::tui::{ - app::{AppPublicState, AppState, Category, IAppAccess, Selection, WidgetState}, + app::{ + AppPublicMatchesInfo, AppPublicState, AppState, Category, IAppAccess, Selection, + WidgetState, + }, ui::{ browse::{ AlbumArea, AlbumState, ArtistArea, ArtistState, FrameArea, TrackArea, TrackState, @@ -30,8 +33,6 @@ use crate::tui::{ }, }; -use super::app::AppPublicMatchesKind; - pub trait IUi { fn render(app: &mut APP, frame: &mut Frame); } @@ -134,7 +135,7 @@ impl Ui { } fn render_matches_overlay( - matches: Option, + matches: Option, state: &mut WidgetState, frame: &mut Frame, ) { @@ -213,8 +214,8 @@ mod tests { } } - impl<'app> AppPublicMatchesKind<'app> { - fn get(&self) -> AppPublicMatchesKind<'app> { + impl<'app> AppPublicMatchesInfo<'app> { + fn get(&self) -> AppPublicMatchesInfo<'app> { match self { Self::Artist(a) => Self::Artist(a.get()), Self::Album(a) => Self::Album(a.get()), @@ -259,15 +260,15 @@ mod tests { fn artist_matches<'app>( matching: &'app Artist, list: &'app [Match], - ) -> AppPublicMatchesKind<'app> { - AppPublicMatchesKind::Artist(AppPublicArtistMatches { matching, list }) + ) -> AppPublicMatchesInfo<'app> { + AppPublicMatchesInfo::Artist(AppPublicArtistMatches { matching, list }) } fn album_matches<'app>( matching: &'app Album, list: &'app [Match], - ) -> AppPublicMatchesKind<'app> { - AppPublicMatchesKind::Album(AppPublicAlbumMatches { matching, list }) + ) -> AppPublicMatchesInfo<'app> { + AppPublicMatchesInfo::Album(AppPublicAlbumMatches { matching, list }) } fn draw_test_suite(collection: &Collection, selection: &mut Selection) {