Implemented as desired
Some checks failed
Cargo CI / Build and Test (pull_request) Failing after 2m38s
Cargo CI / Lint (pull_request) Failing after 1m3s

This commit is contained in:
Wojciech Kozlowski 2024-09-06 21:34:40 +02:00
parent 3f1845ed23
commit 196de92959
3 changed files with 20 additions and 10 deletions

View File

@ -14,8 +14,11 @@ use musichoard::collection::{
use crate::tui::{
app::{
machine::{App, AppInner, AppMachine}, AppMatchesInfo, AppPublic, AppState, IAppEventFetch, IAppInteractFetch
}, event::{Event, EventSender}, lib::interface::musicbrainz::{Error as MbError, IMusicBrainz}
machine::{App, AppInner, AppMachine},
AppMatchesInfo, AppPublic, AppState, IAppEventFetch, IAppInteractFetch,
},
event::{Event, EventSender},
lib::interface::musicbrainz::{Error as MbError, IMusicBrainz},
};
use super::matches::AppMatches;
@ -70,7 +73,7 @@ impl AppMachine<AppFetch> {
AppMachine::error(inner, format!("fetch failed: {fetch_err}")).into()
}
},
Err(try_recv_err) => match try_recv_err {
Err(recv_err) => match recv_err {
TryRecvError::Disconnected => {
if first {
AppMachine::matches(inner, AppMatches::empty(fetch)).into()
@ -102,10 +105,6 @@ impl<'a> From<&'a mut AppMachine<AppFetch>> for AppPublic<'a> {
impl IAppInteractFetch for AppMachine<AppFetch> {
type APP = App;
fn proceed(self) -> Self::APP {
self.into()
}
fn abort(self) -> Self::APP {
AppMachine::browse(self.inner).into()
}

View File

@ -92,7 +92,6 @@ pub trait IAppInteractSearch {
pub trait IAppInteractFetch {
type APP: IAppInteract;
fn proceed(self) -> Self::APP;
fn abort(self) -> Self::APP;
fn no_op(self) -> Self::APP;

View File

@ -131,6 +131,17 @@ impl Ui {
UiWidget::render_overlay_widget("Reload", reload_text, area, false, frame);
}
fn render_fetch_overlay(frame: &mut Frame) {
let area = OverlayBuilder::default().build(frame.size());
UiWidget::render_overlay_widget(
"Fetching",
Paragraph::new(" -- fetching --"),
area,
false,
frame,
)
}
fn render_matches_overlay(
matches: Option<&AppMatchesInfo>,
state: &mut WidgetState,
@ -162,11 +173,12 @@ impl IUi for Ui {
Self::render_browse_frame(collection, selection, &state, frame);
match state {
AppState::Info(_) => Self::render_info_overlay(collection, selection, frame),
AppState::Info(()) => Self::render_info_overlay(collection, selection, frame),
AppState::Reload(()) => Self::render_reload_overlay(frame),
AppState::Fetch(()) => Self::render_fetch_overlay(frame),
AppState::Matches(public) => {
Self::render_matches_overlay(public.matches, public.state, frame)
}
AppState::Reload(_) => Self::render_reload_overlay(frame),
AppState::Error(msg) => Self::render_error_overlay("Error", msg, frame),
AppState::Critical(msg) => Self::render_error_overlay("Critical Error", msg, frame),
_ => {}