More consistent naming
This commit is contained in:
parent
bea62a334e
commit
a53dff123a
@ -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()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<AppPublicMatchesKind<'app>>,
|
||||
pub matches: Option<AppPublicMatchesInfo<'app>>,
|
||||
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 {
|
||||
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!(),
|
||||
}
|
||||
}
|
||||
|
@ -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(),
|
||||
}
|
||||
|
@ -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<AppPublicMatchesKind>, state: &'b mut WidgetState) -> Self {
|
||||
pub fn new(matches: Option<AppPublicMatchesInfo>, 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),
|
||||
}
|
||||
|
@ -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: IAppAccess>(app: &mut APP, frame: &mut Frame);
|
||||
}
|
||||
@ -134,7 +135,7 @@ impl Ui {
|
||||
}
|
||||
|
||||
fn render_matches_overlay(
|
||||
matches: Option<AppPublicMatchesKind>,
|
||||
matches: Option<AppPublicMatchesInfo>,
|
||||
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<Artist>],
|
||||
) -> AppPublicMatchesKind<'app> {
|
||||
AppPublicMatchesKind::Artist(AppPublicArtistMatches { matching, list })
|
||||
) -> AppPublicMatchesInfo<'app> {
|
||||
AppPublicMatchesInfo::Artist(AppPublicArtistMatches { matching, list })
|
||||
}
|
||||
|
||||
fn album_matches<'app>(
|
||||
matching: &'app Album,
|
||||
list: &'app [Match<Album>],
|
||||
) -> AppPublicMatchesKind<'app> {
|
||||
AppPublicMatchesKind::Album(AppPublicAlbumMatches { matching, list })
|
||||
) -> AppPublicMatchesInfo<'app> {
|
||||
AppPublicMatchesInfo::Album(AppPublicAlbumMatches { matching, list })
|
||||
}
|
||||
|
||||
fn draw_test_suite(collection: &Collection, selection: &mut Selection) {
|
||||
|
Loading…
Reference in New Issue
Block a user