Provide a keyboard shortcut to pull all release groups of an artist #233

Merged
wojtek merged 14 commits from 160---provide-a-keyboard-shortcut-to-pull-all-release-groups-of-an-artist into main 2024-12-30 23:42:20 +01:00
Showing only changes of commit 12b27655e3 - Show all commits

View File

@ -140,32 +140,27 @@ impl AppMachine<FetchState> {
}
pub fn app_fetch_next(inner: AppInner, mut fetch: FetchState) -> App {
match fetch.try_recv() {
Ok(fetch_result) => match fetch_result {
Ok(retval) => Self::handle_mb_api_return(inner, fetch, retval),
Err(fetch_err) => {
AppMachine::error_state(inner, format!("fetch failed: {fetch_err}")).into()
}
},
Err(recv_err) => match recv_err {
TryRecvError::Empty => AppMachine::fetch_state(inner, fetch).into(),
TryRecvError::Disconnected => {
loop {
let app: App = match fetch.try_recv() {
Ok(fetch_result) => match fetch_result {
Ok(MbReturn::Match(next_match)) => {
AppMachine::match_state(inner, MatchState::new(next_match, fetch)).into()
}
Ok(MbReturn::Fetch(_)) => continue,
Err(fetch_err) => {
AppMachine::error_state(inner, format!("fetch failed: {fetch_err}")).into()
}
},
Err(TryRecvError::Empty) => AppMachine::fetch_state(inner, fetch).into(),
Err(TryRecvError::Disconnected) => {
if fetch.fetch_rx.is_some() {
AppMachine::browse_state(inner).into()
} else {
Self::app_fetch_new(inner)
}
}
},
}
}
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),
};
return app;
}
}