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)]
use mockall::automock;
use crate::{
core::{
collection::Collection,
interface::database::{IDatabase, LoadError, SaveError},
},
external::database::serde::{deserialize::DeserializeDatabase, serialize::SerializeDatabase},
use crate::core::{
collection::Collection,
interface::database::{IDatabase, LoadError, SaveError},
};
use super::serde::{deserialize::DeserializeDatabase, serialize::SerializeDatabase};
impl From<serde_json::Error> for LoadError {
fn from(err: serde_json::Error) -> LoadError {
LoadError::SerDeError(err.to_string())

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,10 +17,7 @@ use ratatui::{layout::Rect, widgets::Paragraph, Frame};
use musichoard::collection::{album::Album, Collection};
use crate::tui::{
app::{
AppPublicState, AppState, Category, IAppAccess, InputPublic, MatchStateInfo, Selection,
WidgetState,
},
app::{AppPublicState, AppState, Category, IAppAccess, MatchStateInfo, Selection, WidgetState},
ui::{
browse_state::{
AlbumArea, AlbumState, ArtistArea, ArtistState, FrameArea, TrackArea, TrackState,
@ -38,6 +35,8 @@ use crate::tui::{
},
};
use super::app::InputPublic;
pub trait IUi {
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 {
let mut list: Vec<MatchOption<ArtistMeta>> = list.into_iter().map(Into::into).collect();
list.push(MatchOption::CannotHaveMbid);
list.push(MatchOption::ManualInputMbid);
MatchStateInfo::artist(matching, list)
}
fn album_matches(matching: AlbumMeta, list: Vec<Match<AlbumMeta>>) -> MatchStateInfo {
let mut list: Vec<MatchOption<AlbumMeta>> = list.into_iter().map(Into::into).collect();
list.push(MatchOption::CannotHaveMbid);
list.push(MatchOption::ManualInputMbid);
MatchStateInfo::album(matching, list)
}
@ -382,10 +379,6 @@ mod tests {
input: None,
};
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]
@ -421,9 +414,5 @@ mod tests {
input: None,
};
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();
}
}