Congest the code
This commit is contained in:
parent
dde8268eaa
commit
12b27655e3
@ -140,32 +140,27 @@ impl AppMachine<FetchState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn app_fetch_next(inner: AppInner, mut fetch: FetchState) -> App {
|
pub fn app_fetch_next(inner: AppInner, mut fetch: FetchState) -> App {
|
||||||
match fetch.try_recv() {
|
loop {
|
||||||
Ok(fetch_result) => match fetch_result {
|
let app: App = match fetch.try_recv() {
|
||||||
Ok(retval) => Self::handle_mb_api_return(inner, fetch, retval),
|
Ok(fetch_result) => match fetch_result {
|
||||||
Err(fetch_err) => {
|
Ok(MbReturn::Match(next_match)) => {
|
||||||
AppMachine::error_state(inner, format!("fetch failed: {fetch_err}")).into()
|
AppMachine::match_state(inner, MatchState::new(next_match, fetch)).into()
|
||||||
}
|
}
|
||||||
},
|
Ok(MbReturn::Fetch(_)) => continue,
|
||||||
Err(recv_err) => match recv_err {
|
Err(fetch_err) => {
|
||||||
TryRecvError::Empty => AppMachine::fetch_state(inner, fetch).into(),
|
AppMachine::error_state(inner, format!("fetch failed: {fetch_err}")).into()
|
||||||
TryRecvError::Disconnected => {
|
}
|
||||||
|
},
|
||||||
|
Err(TryRecvError::Empty) => AppMachine::fetch_state(inner, fetch).into(),
|
||||||
|
Err(TryRecvError::Disconnected) => {
|
||||||
if fetch.fetch_rx.is_some() {
|
if fetch.fetch_rx.is_some() {
|
||||||
AppMachine::browse_state(inner).into()
|
AppMachine::browse_state(inner).into()
|
||||||
} else {
|
} else {
|
||||||
Self::app_fetch_new(inner)
|
Self::app_fetch_new(inner)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
}
|
return app;
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_mb_api_return(inner: AppInner, fetch: FetchState, retval: MbReturn) -> App {
|
|
||||||
match retval {
|
|
||||||
MbReturn::Match(next_match) => {
|
|
||||||
AppMachine::match_state(inner, MatchState::new(next_match, fetch)).into()
|
|
||||||
}
|
|
||||||
MbReturn::Fetch(_) => Self::app_fetch_next(inner, fetch),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user