Compare commits

..

No commits in common. "cb09f47eb25c076687f8b8faf8cc8672994a8ffb" and "4b92254a4d4b84dd7e79906f9ead4950e204bf58" have entirely different histories.

9 changed files with 27 additions and 35 deletions

View File

@ -5,14 +5,13 @@ pub mod backend;
#[cfg(test)] #[cfg(test)]
use mockall::automock; use mockall::automock;
use crate::{ use crate::core::{
core::{ collection::Collection,
collection::Collection, interface::database::{IDatabase, LoadError, SaveError},
interface::database::{IDatabase, LoadError, SaveError},
},
external::database::serde::{deserialize::DeserializeDatabase, serialize::SerializeDatabase},
}; };
use super::serde::{deserialize::DeserializeDatabase, serialize::SerializeDatabase};
impl From<serde_json::Error> for LoadError { impl From<serde_json::Error> for LoadError {
fn from(err: serde_json::Error) -> LoadError { fn from(err: serde_json::Error) -> LoadError {
LoadError::SerDeError(err.to_string()) LoadError::SerDeError(err.to_string())

View File

@ -4,12 +4,11 @@ use serde::Deserialize;
use crate::{ use crate::{
collection::{artist::ArtistId, musicbrainz::Mbid}, collection::{artist::ArtistId, musicbrainz::Mbid},
external::musicbrainz::api::{ external::musicbrainz::api::SerdeMbid,
search::query::{impl_term, EmptyQuery, EmptyQueryJoin, Query, QueryJoin},
SerdeMbid,
},
}; };
use super::query::{impl_term, EmptyQuery, EmptyQueryJoin, Query, QueryJoin};
pub enum SearchArtist<'a> { pub enum SearchArtist<'a> {
String(&'a str), String(&'a str),
} }

View File

@ -8,11 +8,12 @@ use crate::{
musicbrainz::Mbid, musicbrainz::Mbid,
}, },
external::musicbrainz::api::{ external::musicbrainz::api::{
search::query::{impl_term, EmptyQuery, EmptyQueryJoin, Query, QueryJoin},
ApiDisplay, SerdeAlbumDate, SerdeAlbumPrimaryType, SerdeAlbumSecondaryType, SerdeMbid, ApiDisplay, SerdeAlbumDate, SerdeAlbumPrimaryType, SerdeAlbumSecondaryType, SerdeMbid,
}, },
}; };
use super::query::{impl_term, EmptyQuery, EmptyQueryJoin, Query, QueryJoin};
pub enum SearchReleaseGroup<'a> { pub enum SearchReleaseGroup<'a> {
String(&'a str), String(&'a str),
Arid(&'a Mbid), Arid(&'a Mbid),

View File

@ -14,13 +14,15 @@ use musichoard::collection::{
use crate::tui::{ use crate::tui::{
app::{ app::{
machine::{match_state::MatchState, App, AppInner, AppMachine}, machine::{App, AppInner, AppMachine},
AppPublicState, AppState, IAppEventFetch, IAppInteractFetch, MatchStateInfo, AppPublicState, AppState, IAppEventFetch, IAppInteractFetch, MatchStateInfo,
}, },
event::{Event, EventSender}, event::{Event, EventSender},
lib::interface::musicbrainz::{self, Error as MbError, IMusicBrainz}, lib::interface::musicbrainz::{self, Error as MbError, IMusicBrainz},
}; };
use super::match_state::MatchState;
pub struct FetchState { pub struct FetchState {
fetch_rx: FetchReceiver, fetch_rx: FetchReceiver,
} }

View File

@ -1,11 +1,13 @@
use std::cmp; use std::cmp;
use crate::tui::app::{ use crate::tui::app::{
machine::{fetch_state::FetchState, input::Input, App, AppInner, AppMachine}, machine::{App, AppInner, AppMachine},
AlbumMatches, AppPublicState, AppState, ArtistMatches, IAppInteractMatch, MatchOption, AlbumMatches, AppPublicState, AppState, ArtistMatches, IAppInteractMatch, MatchOption,
MatchStateInfo, MatchStatePublic, WidgetState, MatchStateInfo, MatchStatePublic, WidgetState,
}; };
use super::{fetch_state::FetchState, input::Input};
impl ArtistMatches { impl ArtistMatches {
fn len(&self) -> usize { fn len(&self) -> usize {
self.list.len() self.list.len()

View File

@ -11,10 +11,7 @@ mod search_state;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use crate::tui::{ use crate::tui::{
app::{ app::{selection::Selection, AppPublic, AppPublicInner, AppState, IApp, IAppAccess},
selection::Selection, AppMode, AppPublic, AppPublicInner, AppPublicState, AppState, IApp,
IAppAccess, IAppBase, IAppState,
},
event::EventSender, event::EventSender,
lib::{interface::musicbrainz::IMusicBrainz, IMusicHoard}, lib::{interface::musicbrainz::IMusicBrainz, IMusicHoard},
}; };
@ -29,6 +26,8 @@ use match_state::MatchState;
use reload_state::ReloadState; use reload_state::ReloadState;
use search_state::SearchState; use search_state::SearchState;
use super::{AppMode, AppPublicState, IAppBase, IAppState};
pub type App = AppState< pub type App = AppState<
AppMachine<BrowseState>, AppMachine<BrowseState>,
AppMachine<InfoState>, AppMachine<InfoState>,

View File

@ -5,13 +5,14 @@ use mockall::automock;
use crate::tui::{ use crate::tui::{
app::{ app::{
AppMode, AppState, Delta, IApp, IAppBase, IAppEventFetch, IAppInput, IAppInteractBrowse, AppState, Delta, IApp, IAppInteractBrowse, IAppInteractError, IAppInteractFetch,
IAppInteractError, IAppInteractFetch, IAppInteractInfo, IAppInteractMatch, IAppInteractInfo, IAppInteractMatch, IAppInteractReload, IAppInteractSearch,
IAppInteractReload, IAppInteractSearch,
}, },
event::{Event, EventError, EventReceiver}, event::{Event, EventError, EventReceiver},
}; };
use super::app::{AppMode, IAppBase, IAppEventFetch, IAppInput};
#[cfg_attr(test, automock)] #[cfg_attr(test, automock)]
pub trait IEventHandler<APP: IApp> { pub trait IEventHandler<APP: IApp> {
fn handle_next_event(&self, app: APP) -> Result<APP, EventError>; fn handle_next_event(&self, app: APP) -> Result<APP, EventError>;

View File

@ -4,7 +4,7 @@ use std::thread;
#[cfg(test)] #[cfg(test)]
use mockall::automock; use mockall::automock;
use crate::tui::event::{Event, EventError, EventSender}; use super::event::{Event, EventError, EventSender};
#[cfg_attr(test, automock)] #[cfg_attr(test, automock)]
pub trait IEventListener { pub trait IEventListener {

View File

@ -17,10 +17,7 @@ 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::{ app::{AppPublicState, AppState, Category, IAppAccess, MatchStateInfo, Selection, WidgetState},
AppPublicState, AppState, Category, IAppAccess, InputPublic, MatchStateInfo, Selection,
WidgetState,
},
ui::{ ui::{
browse_state::{ browse_state::{
AlbumArea, AlbumState, ArtistArea, ArtistState, FrameArea, TrackArea, TrackState, AlbumArea, AlbumState, ArtistArea, ArtistState, FrameArea, TrackArea, TrackState,
@ -38,6 +35,8 @@ use crate::tui::{
}, },
}; };
use super::app::InputPublic;
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);
} }
@ -253,14 +252,12 @@ mod tests {
fn artist_matches(matching: ArtistMeta, list: Vec<Match<ArtistMeta>>) -> MatchStateInfo { fn artist_matches(matching: ArtistMeta, list: Vec<Match<ArtistMeta>>) -> MatchStateInfo {
let mut list: Vec<MatchOption<ArtistMeta>> = list.into_iter().map(Into::into).collect(); let mut list: Vec<MatchOption<ArtistMeta>> = list.into_iter().map(Into::into).collect();
list.push(MatchOption::CannotHaveMbid); list.push(MatchOption::CannotHaveMbid);
list.push(MatchOption::ManualInputMbid);
MatchStateInfo::artist(matching, list) MatchStateInfo::artist(matching, list)
} }
fn album_matches(matching: AlbumMeta, list: Vec<Match<AlbumMeta>>) -> MatchStateInfo { fn album_matches(matching: AlbumMeta, list: Vec<Match<AlbumMeta>>) -> MatchStateInfo {
let mut list: Vec<MatchOption<AlbumMeta>> = list.into_iter().map(Into::into).collect(); let mut list: Vec<MatchOption<AlbumMeta>> = list.into_iter().map(Into::into).collect();
list.push(MatchOption::CannotHaveMbid); list.push(MatchOption::CannotHaveMbid);
list.push(MatchOption::ManualInputMbid);
MatchStateInfo::album(matching, list) MatchStateInfo::album(matching, list)
} }
@ -382,10 +379,6 @@ mod tests {
input: None, input: None,
}; };
terminal.draw(|frame| Ui::render(&mut app, frame)).unwrap(); terminal.draw(|frame| Ui::render(&mut app, frame)).unwrap();
let input = tui_input::Input::default();
app.input = Some(&input);
terminal.draw(|frame| Ui::render(&mut app, frame)).unwrap();
} }
#[test] #[test]
@ -421,9 +414,5 @@ mod tests {
input: None, input: None,
}; };
terminal.draw(|frame| Ui::render(&mut app, frame)).unwrap(); terminal.draw(|frame| Ui::render(&mut app, frame)).unwrap();
let input = tui_input::Input::default();
app.input = Some(&input);
terminal.draw(|frame| Ui::render(&mut app, frame)).unwrap();
} }
} }