Handle idle time between fetch results #212
@ -14,8 +14,11 @@ use musichoard::collection::{
|
|||||||
|
|
||||||
use crate::tui::{
|
use crate::tui::{
|
||||||
app::{
|
app::{
|
||||||
machine::{App, AppInner, AppMachine}, AppMatchesInfo, AppPublic, AppState, IAppEventFetch, IAppInteractFetch
|
machine::{App, AppInner, AppMachine},
|
||||||
}, event::{Event, EventSender}, lib::interface::musicbrainz::{Error as MbError, IMusicBrainz}
|
AppMatchesInfo, AppPublic, AppState, IAppEventFetch, IAppInteractFetch,
|
||||||
|
},
|
||||||
|
event::{Event, EventSender},
|
||||||
|
lib::interface::musicbrainz::{Error as MbError, IMusicBrainz},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::matches::AppMatches;
|
use super::matches::AppMatches;
|
||||||
@ -70,7 +73,7 @@ impl AppMachine<AppFetch> {
|
|||||||
AppMachine::error(inner, format!("fetch failed: {fetch_err}")).into()
|
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 => {
|
TryRecvError::Disconnected => {
|
||||||
if first {
|
if first {
|
||||||
AppMachine::matches(inner, AppMatches::empty(fetch)).into()
|
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> {
|
impl IAppInteractFetch for AppMachine<AppFetch> {
|
||||||
type APP = App;
|
type APP = App;
|
||||||
|
|
||||||
fn proceed(self) -> Self::APP {
|
|
||||||
self.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn abort(self) -> Self::APP {
|
fn abort(self) -> Self::APP {
|
||||||
AppMachine::browse(self.inner).into()
|
AppMachine::browse(self.inner).into()
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,6 @@ pub trait IAppInteractSearch {
|
|||||||
pub trait IAppInteractFetch {
|
pub trait IAppInteractFetch {
|
||||||
type APP: IAppInteract;
|
type APP: IAppInteract;
|
||||||
|
|
||||||
fn proceed(self) -> Self::APP;
|
|
||||||
fn abort(self) -> Self::APP;
|
fn abort(self) -> Self::APP;
|
||||||
|
|
||||||
fn no_op(self) -> Self::APP;
|
fn no_op(self) -> Self::APP;
|
||||||
|
@ -131,6 +131,17 @@ impl Ui {
|
|||||||
UiWidget::render_overlay_widget("Reload", reload_text, area, false, frame);
|
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(
|
fn render_matches_overlay(
|
||||||
matches: Option<&AppMatchesInfo>,
|
matches: Option<&AppMatchesInfo>,
|
||||||
state: &mut WidgetState,
|
state: &mut WidgetState,
|
||||||
@ -162,11 +173,12 @@ impl IUi for Ui {
|
|||||||
|
|
||||||
Self::render_browse_frame(collection, selection, &state, frame);
|
Self::render_browse_frame(collection, selection, &state, frame);
|
||||||
match state {
|
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) => {
|
AppState::Matches(public) => {
|
||||||
Self::render_matches_overlay(public.matches, public.state, frame)
|
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::Error(msg) => Self::render_error_overlay("Error", msg, frame),
|
||||||
AppState::Critical(msg) => Self::render_error_overlay("Critical Error", msg, frame),
|
AppState::Critical(msg) => Self::render_error_overlay("Critical Error", msg, frame),
|
||||||
_ => {}
|
_ => {}
|
||||||
|
Loading…
Reference in New Issue
Block a user