Add manual input elements to the app an ui #216

Merged
wojtek merged 17 commits from 188---add-option-for-manual-input-during-fetch into main 2024-09-15 15:20:11 +02:00
9 changed files with 25 additions and 27 deletions
Showing only changes of commit dd3633cd5f - Show all commits

View File

@ -5,13 +5,14 @@ pub mod backend;
#[cfg(test)] #[cfg(test)]
use mockall::automock; use mockall::automock;
use crate::core::{ use crate::{
collection::Collection, core::{
interface::database::{IDatabase, LoadError, SaveError}, collection::Collection,
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,11 +4,12 @@ use serde::Deserialize;
use crate::{ use crate::{
collection::{artist::ArtistId, musicbrainz::Mbid}, collection::{artist::ArtistId, musicbrainz::Mbid},
external::musicbrainz::api::SerdeMbid, external::musicbrainz::api::{
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,12 +8,11 @@ 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,15 +14,13 @@ use musichoard::collection::{
use crate::tui::{ use crate::tui::{
app::{ app::{
machine::{App, AppInner, AppMachine}, machine::{match_state::MatchState, 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,13 +1,11 @@
use std::cmp; use std::cmp;
use crate::tui::app::{ use crate::tui::app::{
machine::{App, AppInner, AppMachine}, machine::{fetch_state::FetchState, input::Input, 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,7 +11,10 @@ mod search_state;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use crate::tui::{ use crate::tui::{
app::{selection::Selection, AppPublic, AppPublicInner, AppState, IApp, IAppAccess}, app::{
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},
}; };
@ -26,8 +29,6 @@ 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,14 +5,13 @@ use mockall::automock;
use crate::tui::{ use crate::tui::{
app::{ app::{
AppState, Delta, IApp, IAppInteractBrowse, IAppInteractError, IAppInteractFetch, AppMode, AppState, Delta, IApp, IAppBase, IAppEventFetch, IAppInput, IAppInteractBrowse,
IAppInteractInfo, IAppInteractMatch, IAppInteractReload, IAppInteractSearch, IAppInteractError, IAppInteractFetch, IAppInteractInfo, IAppInteractMatch,
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 super::event::{Event, EventError, EventSender}; use crate::tui::event::{Event, EventError, EventSender};
#[cfg_attr(test, automock)] #[cfg_attr(test, automock)]
pub trait IEventListener { pub trait IEventListener {

View File

@ -17,7 +17,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, MatchStateInfo, Selection, WidgetState}, app::{
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,
@ -35,8 +38,6 @@ 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);
} }